Idiomatic portable way to strip line endings? (fwd)

Russ Cox rsc at plan9.bell-labs.com
Sun Dec 16 15:50:16 EST 2001


As has already been pointed out, section 7.19.2 of
the ANSI C99 standard mandates that stdio FILEs
opened in text mode are sequences of lines, each
of which is terminated with a newline character.
I believe this was the case for the C89 standard too.

If you open in binary mode then you have to deal
with the differing line-ending conventions on 
various systems.  If you open in text mode, you
should always get a single \n (\012); nothing more,
nothing less. 

Russ





More information about the Python-list mailing list