[ python-Bugs-1305706 ] windows unicode write is messing up the EOL.
SourceForge.net
noreply at sourceforge.net
Tue Sep 27 21:57:10 CEST 2005
Bugs item #1305706, was opened at 2005-09-27 12:43
Message generated for change (Comment added) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1305706&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Windows
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Istvan Visegradi (visike)
Assigned to: Nobody/Anonymous (nobody)
Summary: windows unicode write is messing up the EOL.
Initial Comment:
User has an Unicode UTF-16 input file and trys to read
it line-by-line and write it back to a new file.
With the read line the program does nothing.
code example:
...
ln=fi.readline()
fo.write(ln)
...
In linux this code works perfectly with the input
UTF-16 type file.
In windows Python put an extra \x0D into the EOL.
EOL should look like: 0D 00 0A 00
In windows it will be: 0D 00 0D 0A 00
Please inform when correction is available.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2005-09-27 21:57
Message:
Logged In: YES
user_id=21627
Can you provide a small test program that demonstrates the
problem?
I cannot reproduce it:
>>> f=codecs.open("f.txt","w",encoding="utf-16")
>>> f.write(u"Hallo\n")
>>> f.write(u"Welt\r\n")
>>> f.close()
>>> open("f.txt").read()
'\xff\xfeH\x00a\x00l\x00l\x00o\x00\n\x00W\x00e\x00l\x00t\x00\r\x00\n\x00'
This looks right to me.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1305706&group_id=5470
More information about the Python-bugs-list
mailing list