lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


This is neither a Lua nor a C thing. It is actually a peculiarity of CP/M / MSDOS / Windows, which have two modes for reading files:

A text mode where a newline is "corrected" to CR-LF, and the end of the file is at the first ^Z ('\x1A'),
and a binary mode where this processing is not done.

When you open a PNG file, you will by design (of the file) need binary mode on those systems.

Oliver

Two
===
The documentation for `io.open` mentions opening a file in binary mode:

The mode string can also have a 'b' at the end, which is needed in some
systems to open the file in binary mode.
Perhaps this explanation is enough for someone who knows C. But as
someone who is simply a Lua user (not an embedder), this sentence is
vague. Is it possible to add more detail or is this one of the
implementation-defined things?

Best regards,
Aman