[Python-Dev] Re: [XML-SIG] printing Unicode xml to StringIO (original) (raw)

Martin v. Loewis martin@v.loewis.de
Fri, 28 Dec 2001 18:02:17 +0100


Unicode support in cStringIO would require a new implementation since the machinery uses raw byte buffers.

Not necessarily. You could add a flag saying that whether those bytes represent Unicode strings or not. If they do, you pick an encoding of your choice (perhaps unicode-internal), and convert the existing bytes to that encoding on first sighting of a Unicode string (assuming that everything so far is in the system encoding). When returning the bytes to the user, you build a Unicode object if the flag is set.

Of course, you'd still have to touch every method, to analyse the flag...

Regards, Martin