[Tutor] Re: deleting CR within files

Andrei project5 at redrival.net
Thu Apr 15 12:43:48 EDT 2004


David Talaga wrote on Thursday 15 April 2004 15:38:
> Here is my next problem.  I am trying to rid some files of pesky <CR> from
> files.  Here is my code.  Any help would be great!

Perhaps you should mention what the problem is, not just the code. Just
guessing here, are you writing a file containing '\n' on Windows? If so,
those '\n' get automatically expanded to '\r\n' because that's the way
Windows does newlines. The only way to get around this (AFAIK) is to open
both files in binary body ('rb' respectively 'wb') and read one character
at a time. If that character's ord() is 10 (or is <CR> 13? I keep mixing
them up), don't write it to the out_file, otherwise do write it. 



Real contact info (decode with rot13):
cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.

More information about the Tutor mailing list