Talk:Read entire file: Difference between revisions

→‎Fortran: new section
(→‎Encoding selection: bytes vs chars)
(→‎Fortran: new section)
Line 10:
 
: It depends on whether you're reading the file as a sequence of bytes or as a sequence of characters. The encoding is only required when converting from bytes to characters (or ''vice versa'', of course). Failure to properly distinguish between the two concepts has been the cause of a huge amount of pain over the past decade or two, pain which we're only gradually emerging from as an industry. Thank goodness for Unicode and UTF-8. –[[User:Dkf|Donal Fellows]] 22:43, 7 March 2013 (UTC)
 
== Fortran ==
 
There was some stuff pretending that it's impossible to read the file into memory, and that the only way is some convoluted loop, with goto (!). Sorry, that's wrong as of the current Fortran standard. I replaced this garbage with an example allocating a character string exactly the right size, and reading the file in stream access.
 
I also showed another example using Intel Fortran, that makes use of the Windows API to create a memory map of the file.
 
[[User:Arbautjc|Arbautjc]] ([[User talk:Arbautjc|talk]]) 20:00, 11 November 2016 (UTC)
Anonymous user