Re: Read a line under MS/Unix/Mac
- From: "Charlie Gordon" <news@xxxxxxxxxxx>
- Date: Mon, 12 Nov 2007 02:29:09 +0100
"Keith Thompson" <kst-u@xxxxxxx> a écrit dans le message de news:
lny7dctc69.fsf@xxxxxxxxxxxxxxxxxx
user923005 <dcorbit@xxxxxxxxx> writes:
[...]
[...]in Art of C) to read a file with the lines ended in any format:
Microsoft-style CR/LF pair, Unix-style NL, or Mac-style CR.
Don't forget that Macs use '\r', Unix uses '\n' and Windows systems
use "\r\n".
I don't think he's forgotten that.
But note that the '\n' encoding in C refers to a "new-line" character,
which isn't necessarily an ASCII LF character. On an old Mac system,
I would guess that '\n' is actually the ASCII CR character (either
that, or stdio translates CR to LF on input).
So reading an untranslated MS/DOS file on a Mac would result in bogus
interpretation of 0x0D/0x0A pairs: does the Mac C runtime translate those
into a single \n ? Do unix native text files get read as a single long
unterminated line ? This would happen in both text and binary mode. Is
there even a difference between text and binary more on older Macs ?
--
Chqrlie.
.
- References:
- Read a line under MS/Unix/Mac
- From: mazwolfe
- Re: Read a line under MS/Unix/Mac
- From: user923005
- Re: Read a line under MS/Unix/Mac
- From: Keith Thompson
- Read a line under MS/Unix/Mac
- Prev by Date: Re: Keith Thompson's messages dont come through
- Next by Date: Re: What's the deal with size_t?
- Previous by thread: Re: Read a line under MS/Unix/Mac
- Next by thread: Re: Read a line under MS/Unix/Mac
- Index(es):
Relevant Pages
|