The Art of Pickling: Binary vs Ascii difficulties

Andrew Dalke adalke at mindspring.com
Thu Oct 14 18:13:27 EDT 2004


Scott David Daniels
> This C convention is a violation of the ASCII code as it was then
> defined, in order to save a byte per line (treating '\n' as end-of-line,
> not line-feed).  An ASCII-conforming printer when fed 'a\nb\nc\r\n.\r\n'
> should print:
> a
>  b
>   c
> ..

Standards wonk that I am, I was curious about this.  I've
never read the ASCII spec before.  In my somewhat cursory
search I couldn't find something authoritative on-line that
claimed to be "the" ASCII spec.  I did find RFC 20 "ASCII
format for network interchange" dated October 16, 1969,
so before the C convention was defined.  Here's one copy
   http://www.faqs.org/rfcs/rfc20.html

It says


       LF (Line Feed): A format effector which controls the movement of
    the printing position to the next printing line.  (Applicable also to
    display devices.) Where appropriate, this character may have the
    meaning "New Line" (NL), a format effector which controls the
    movement of the printing point to the first printing position on the
    next printing line.  Use of this convention requires agreement
    between sender and recipient of data.

So it seems that it's not a violation, just a convention.

It happens that MS Windows and Unix (and old Macs) have
different conventions.

				Andrew
				dalke at dalkescientific.com



More information about the Python-list mailing list