[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Two documentation suggestions
- From: William Ahern <william@...>
- Date: Tue, 10 Nov 2020 12:47:28 -0800
On Tue, Nov 10, 2020 at 05:43:14PM +0100, Viacheslav Usov wrote:
> On Tue, Nov 10, 2020 at 2:27 PM Oliver Kroth <email@example.com> wrote:
> > This is neither a Lua nor a C thing.
> This is a C (standard library) thing, because this is documented in
> the C language standards.
> > It is actually a peculiarity of > CP/M / MSDOS / Windows, which have two modes for reading files:
> Neither MS-DOS nor Windows have two file modes that would be similar
> to the C "binary" and "text" "streams" (with reference to, e.g., ISO
> C99 Standard 7.19.2). MS-DOS and Windows API expose files as bytes
> streams (or possibly sequences of fixed-size blocks of bytes), and
> they most certainly do not do any kind of translation.
Microsoft's documentation for fread says,
If the given stream is opened in text mode, Windows-style newlines are
converted into Unix-style newlines. That is, carriage return-line feed
(CRLF) pairs are replaced by single line feed (LF) characters
and for fwrite says,
If stream is opened in text mode, each line feed is replaced with a
carriage return-line feed pair.
I assume (Classic) Mac OS performed similar translation as it used a single
carriage return for EOL.