From: "Adam D. Moss" <adam@gimp.org>
Reply-To: Lua list <lua@bazar2.conectiva.com.br>
To: Lua list <lua@bazar2.conectiva.com.br>
Subject: Re: file read problem
Date: Wed, 16 Nov 2005 10:19:14 +0000
Philippe Lhoste wrote:
Try "rb" and "wb" as the 2-nd parameter to io.open().
Yes, that's that. I tested this code on a Unix-style file (the Lua manual)
and since I ran it on Windows, I actually got a bigger file: LFs were
transformed to CR+LFs.
Binary files were indeed truncated. Probably on first \0 found... Adding b
is the way to go with binary files or if you want to preserve original
EOL.
IIRC, ^Z was treated as an EOF marker on 'DOS text' files.
Regards,
--Adam