[ python-Feature Requests-920680 ] readline not implemented for
UTF-16
SourceForge.net
noreply at sourceforge.net
Wed May 19 04:19:06 EDT 2004
Feature Requests item #920680, was opened at 2004-03-21 23:37
Message generated for change (Comment added) made by lemburg
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=920680&group_id=5470
Category: Unicode
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Bob Ippolito (etrepum)
>Assigned to: M.-A. Lemburg (lemburg)
Summary: readline not implemented for UTF-16
Initial Comment:
The StreamReader for UTF-16 (all three of them) doesn't
implement readline.
----------------------------------------------------------------------
>Comment By: M.-A. Lemburg (lemburg)
Date: 2004-05-19 10:19
Message:
Logged In: YES
user_id=38388
Thanks for the patch. Some comments:
* Unicode has a lot more line-end markers than just LF;
you should use .splitlines() to break lines at all of them
* please collapse both methods (sized + unsized) into
one method and default to 256 bytes for the buffer
size
----------------------------------------------------------------------
Comment By: Bob Ippolito (etrepum)
Date: 2004-05-19 01:22
Message:
Logged In: YES
user_id=139309
I've attached a monkeypatch to get readline support for utf-16 codecs..
import utf16reader
utf16reader.install()
It can be trivially inserted into the utf16 encodings implementation.. it
would be really cool if someone would audit the implementation and
sneak it in before Python 2.4 :)
----------------------------------------------------------------------
Comment By: Bob Ippolito (etrepum)
Date: 2004-03-21 23:54
Message:
Logged In: YES
user_id=139309
I don't need it enough to write a patch, but this is what I used instead..
and it seems like it might work:
try:
for line in inFile:
tline = translator(line)
outFile.write(tline)
except NotImplementedError:
BUFFER = 16384
bytes = inFile.read(BUFFER)
while bytes:
lines = bytes.split(u'\n')
bytes = lines.pop()
for line in lines:
tline = translator(line)
outFile.write(tline)
newbytes = inFile.read(BUFFER)
bytes += newbytes
if not newbytes and bytes:
bytes += u'\n'
----------------------------------------------------------------------
Comment By: M.-A. Lemburg (lemburg)
Date: 2004-03-21 23:44
Message:
Logged In: YES
user_id=38388
Patches are welcome :-)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=920680&group_id=5470
More information about the Python-bugs-list
mailing list