bug-coreutils
[Top][All Lists]
Advanced

[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 1.5.0.13 (X11/20070824)

-----BEGIN PGP SIGNED MESSAGE-----
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.)

<snip>

> 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...
http://micah.cowan.name/

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

iD8DBQFG4Dv97M8hyUobTrERCO6iAJ9GUkHNguGsI4HSLe+Zv+R+4RANjQCeJRB7
sut0YDPbVzMqXYaS4l+vaJ0=
=9WqM
-----END PGP SIGNATURE-----




reply via email to

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