[Top][All Lists]

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

Re: Text tools, line endings, and O_TEXT

From: Micah Cowan
Subject: Re: Text tools, line endings, and O_TEXT
Date: Thu, 06 Sep 2007 10:42:21 -0700
User-agent: Thunderbird (X11/20070824)

Hash: SHA256

John Cowan wrote:

> Indeed, I'd like to see all text tools accept all six known line ending
> conventions:  CR+LF, CR alone, LF alone, NEL alone, CR+NEL, LS.
> (NEL is U+0085, LS is U+2028.)


> That said, I believe it is good for portability to use O_TEXT
> and O_BINARY (and their stdio equivalents) in all software intended
> to be portable.  Unix-tradition systems won't benefit, but it doesn't
> cost anything either; other systems will be enabled to DTRT as a result.

If you intend for all text tools to recognize all line endings, wouldn't
it be better to always open in binary mode so the program can handle the
line-endings? Relying on the system to translate _some_ line-endings
seems problematic, since you won't know which (if any) the system will
handle. The original could have been CR+CR+LF, with the system
translating it as CR+LF, or even LF+LF+LF (some versions of Mac OS?),
and you wouldn't be able to tell the difference.

BTW, are there systems that use CR+NEL as their canonical line
terminator, and if so, which ones? That seems silly, since AFAICT NEL
was intended to replace CR+LF (ISO-6429/Ecma-048 defines it as moving to
to "the line home position of the following line", adjusting for
implicit movement direction). But then, I'm not even familiar with
systems that use NEL as a line terminator in the first place, so my
ignorance is not at all surprising. ;)

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...

Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]