Idiomatic portable way to strip line endings? (fwd)

John Roth johnroth at ameritech.net
Mon Dec 17 07:44:08 EST 2001


The poster child of a Windows application which does not
do this is Notepad. However, Notepad may be reading the
file as binary; it does other strange things.

The few other applications I use for text all seem to do
it right.

John Roth

"Peter Ring" <pri at magnus.dk> wrote in message
news:3c1da747$0$94397$edfadb0f at dspool01.news.tele.dk...
> Except that files do respect operating system boundaries, the most
common
> cases being LF-style files appearing in Win32 applications and
CR/LF-style
> files appearing in *nix applications. In general, it's plain silly to
> convert end-of-records just because files are moved around or opened
> (through a file system) by a process with another run-time library.
Some
> operating systems (e.g., VMS) might require a record format conversion
for
> at least some files, but it's not really the general case.
>
> Kind regards
> Peter Ring
>
> "Russ Cox" <rsc at plan9.bell-labs.com> wrote in message
> news:mailman.1008535879.30802.python-list at python.org...
> > 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