Re: Unexpected result using file:read("l")
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Unexpected result using file:read("l")
- From: Francisco Olarte <folarte@...>
- Date: 2022年3月24日 16:02:58 +0100
Mitchell:
On 2022年3月24日 at 15:39, Mitchell <lists@triplequasar.com> wrote:
> I don't have a Windows box to test this on, but if I recall correctly, opening the file in binary mode on Windows should allow 'l' to also trim '\r'. I could be misremembering though.
It is the other way round. Opening a file in binary gives you
uninterpreted bytes. The C runtime ( on which lua builds ) is supposed
to translate whatever you os uses for end of line into a '\n'. So a
file "ab012円bc015円de015円012円" is read the same in every OS in binary
mode, but you may have problems (CP/M like CRLF, unixlike LF or
Macintosh(classic, not osx) CR ).
In default (text) mode they could be read differently. Also, normally
it is not a good idea to use binary mode for text files, or viceversa.
Francisco Olarte.
>
> Cheers,
> Mitchell