[XML-SIG] using PyXML on a string

"Martin v. Löwis" martin@v.loewis.de
Mon, 26 May 2003 08:54:06 +0200


Paul Tremblay wrote:
> Thanks. The documentation for cStringIO implies that you can't pass to
> it a string containing unicode with values above 128. However, I found
> the exact opposite to be true. If I pass a string containing uincode
> above 128 to StringI0, I get a unicode error. If I use cStringIO, I
> get no error.

Hmm. There is no such thing as a "string containing unicode", atleast 
not if, by "string", you really mean <type 'string'>. You only can pass
<type 'string'> to cStringIO, not <type 'unicode'>. I usually call 
objects of <type 'string'> 'byte strings', and objects of <type 
'unicode'> 'Unicode strings'. IOW, cStringIO supports only byte strings,
whereas StringIO supports both byte strings and Unicode strings. In one
Python release, there was a bug and StringIO rejected Unicode strings. 
cStringIO has never supported Unicode strings, and never will.

Regards,
Martin