[Python-3000] Comment on iostack library

David Hopwood david.nospam.hopwood at blueyonder.co.uk
Fri Sep 1 04:53:21 CEST 2006


tomer filiba wrote:
> [Talin]
> 
>>Well, as far as readline goes: In order to split the text into lines,
>>you have to decode the text first anyway, which is a layer 3 operation.
>>You can't just read bytes until you get a \n, because the file you are
>>reading might be encoded in UCS2 or something.
> 
> well, the LineBufferedLayer can be "configured" to split on any
> "marker", i.e.: LineBufferedLayer(stream, marker = "\x00\x0a")
> and of course layer 3, which creates layer 2, can set this marker
> to any byte sequence. note it's a *byte* sequence, not chars,
> since this passes down to layer 1 transparently.

That isn't what is required; for big-endian UCS-2 or UTF-16, "\x00\x0a"
should only be recognized as LF if it is at an even byte position.

-- 
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>




More information about the Python-3000 mailing list