Re: Read a line under MS/Unix/Mac



"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.


.



Relevant Pages

  • Re: FTP is truncating last character in ASCII mode
    ... Binary mode. ... we need to use ASCII ... line-end characters may be translated coming _and_ going, and with Windows when you open a file in ASCII mode, the file ends at the first ^Z character. ... Woodinville WA 98072-8661 | WFTPD, WFTPD Pro are Windows FTP servers. ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: How do I save a word document to a floopy disk?
    ... ASCII seems to be a Windoze thing these days - Tiger does not appear to have ... Under the Mac OS you don't hold down Alt and key in a number on the numerical ... Character Palette. ... Under OS X they are Unicode only and my news-reader does not support them. ...
    (microsoft.public.publisher)
  • Re: what does "serialization" mean?
    ... Sorry eddie, but you're dead wrong there as usual. ... >>How about ASCII character 0xB0, ... > Totalitarians and Fascists are often self-appointed language police. ...
    (comp.programming)
  • Re: what does "serialization" mean?
    ... > attempt to present myself as an authority on any and every topic I have ... >> survived and EBCDIC did not because ASCII properly sequenced letters. ... > How about ASCII character 0xB0, ... >> must assert negative facts, for all he knows is there is no knowledge ...
    (comp.programming)
  • Re: Cohens paper on byte order
    ... I think you're using "ASCII" in a notional sense. ... a good reason to teach the *opposite* convention, ... Computers should be as easy to understand as is possible _without_ ... arithmetic on character strings ...
    (sci.crypt)