[net.unix-wizards] CR & LF

Lepreau@Utah-20@sri-unix (09/06/82)

From: Jay Lepreau <Lepreau@Utah-20>
Date:  3 Sep 1982 0539-MDT
Nope, if you only use a single char as line terminator it has to be LF, not CR,
because a lone CR has a very reasonable and useful formatting function whereas
a LF does not-- certainly not in practice anyway.  And it's the CRLF pair which
is the line terminator in those other systems (and FTP), not CR itself.

It's the 2 vs 1 chars which REALLY make for porting trouble, not what the
actual chars are.  Seeks really blow it then.
-Jay Lepreau
-------

FC01@Usc-Ecl@sri-unix (09/06/82)

From: FC01 <FC01@Usc-Ecl>
Date:  3 Sep 1982 0739-PDT
Jay,
	Every system I have ever seen (except for DG) requires a <cr> as end of
line on input, not <lf> and not <cr><lf>. Evey system I've seen uses <cr><lf> as
end of line output (although <cr> is certainly useful for special format output)
and <lf> is rarely used for formatting. On the other hand, the reason for using
<lf> is to delimit lines, not to indicate output format - you may notice that
programs that handle output have to use <cr><lf> as a replacement for <lf> each
time they do output and have to convert <cr> to <lf> on input to use <lf> as
the end of line character. It just seems to me you nearly always save one
conversion, and often save two conversins by using <cr> as EOL instead of <lf>.
On input you always save <cr> to <lf> (although you still have to echo <cr><lf>.
On output you rarely lose by converting <cr> to <cr><lf> rather than converting
<lf> to <cr><lf> (in fact the code for the former can be done more quickly since
you always do the first output and simply skip the <lf> if the char was not a
<cr>). On file transfer you can use <cr> rather than <cr><lf> (I've never seen
an input routine that expects <cr><lf>, they all take <cr> as far as I know),
and thus save the conversion from <lf> to whatever and from whatever to <lf>
by simply using <cr> everywhere. Seeks work the same whether you use <cr> or
<lf> as the magic eol character.
			Fred
-------

mark (09/08/82)

There are, of course, lots of headaches caused by using LF as newline,
because LF also has a useful formatting function.  (It's the fastest
way to go down a line, and the only way to scroll, on a typical CRT
terminal, for example.)  It is unfortunate that the NL character chosen
was not some other control character, such as US.  But there are now
a good many programs out there that assume that to get the linefeed
character, they use \n.  Too bad there isn't a \l escape in C for
people that want linefeed to use.