[Smaug] CR/LF, wordwrap, newline & ASCII

Brandon Edward Bickford bran at cats.ucsc.edu
Thu, 13 Jun 2002 22:44:50 -0700 (PDT)

Since no one seemed to respond to this all that well, I believe the answer
to your question is kind of complicated by the fact that it's mostly up to
the programmer.  That is, at any point someone can put in a cr, cr/lf, or
lf into a file using the ascii character codes, and start any convention
they so desire.  

Basically, though, no one does that (for the most part).  Most people I
know just use "\n" in a string whenever they want a newline, and the
compiler, library, or interpreter (depending upon your particular leaning) 
abstracts everything and figures out whether it should be a "cr", "cr/lf"
or "lf" to suit the convention for the platform.  Then again, not too many
people in the windows/mac world seem to use plaintext anymore (yay for
obfuscated formats!), so it seems to be less and less of an issue each
year (I'm not sure why apple had to extend the breakage into os x..).
Usually just opening a file (via something like open() ) will not
translate eol for you and modify your file, but that is highly dependent
upon the software you're using (code can do whatever it damn well
pleases), so it sort of depends upon whether you're talking about mac os
or wintermute os.

End of line characters are inserted into ascii text data to signify a line
break.  This can come in the form of a text editor user hitting the enter
key, a program dumping to stdout, a user pumping porn through aalib, or a
quadrillion other things.  All machines which display ascii text almost
certainly have an end of line character.


On Thu, 13 Jun 2002, Paul Thomas wrote:

> On Thu, 13 Jun 2002, Rick Moen wrote:
> > MacOS terminates ASCII lines with CR (ASCII #13 decimal = D hex).
> > Unix terminates ASCII lines with LF (ASCII #10 decimal = A hex).
> >    (Presumably, MacOS X and Apple Darwin are exceptions.)
> > MS-DOS terminates ASCII lines with CR LF.
> Hey thanks Rick and everyone else for the great responses. I'm 
> being taken to task on this issue and my position has been basically
> what you all have reaffirmed, but, one last question just to be
> sure.
> On which machine are these end of line characters inserted? I have
> always presumed them to be inserted by the 'text editor' that is
> composing the file. Is this wrong? They are not inserted by the
> 'text editor' opening the file are they?
> Thanks again,
> --Paul
> --
> William J. Broad: "The crux... is that the vast majority of the mass
> of the universe seems to be missing."
> _______________________________________________
> Smaug mailing list
> Smaug@lists.svlug.org
> http://lists.svlug.org/lists/listinfo/smaug
> Smaug home page: http://www.scruz.org/

Brandon Bickford