[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: file read problem
- From: "Mark Meijer" <meijer78@...>
- Date: Wed, 16 Nov 2005 12:24:10 +0000
Ah yes *doh*... Thanks all for your replies. I haven't been able to test it
yet but I don't doubt that my problem is hereby solved. However obvious it
was, it didn't occur to me before because lua generally doesn't tend to care
about the contents of a string (such as \0, ^Z, LF/CR), nor perform any
conversions. That is the mindset I'm in when programming in lua. Also at a
glance, the manual entry for io.open didn't of course list the "rb" option
explicitly, but now I do remember having read once that it takes all the
same arguments as its C counterpart.
Sorry, and thanks :-)
From: "Adam D. Moss" <firstname.lastname@example.org>
Reply-To: Lua list <email@example.com>
To: Lua list <firstname.lastname@example.org>
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
IIRC, ^Z was treated as an EOF marker on 'DOS text' files.