[XML-SIG] using PyXML on a string

Paul Tremblay phthenry@earthlink.net
Mon, 26 May 2003 14:16:51 -0400


On Mon, May 26, 2003 at 08:54:06AM +0200, "Martin v. Löwis" wrote:
> 
> 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.
> 

This is from my code:


    file = cStringIO.StringIO(u'<doc>\u00f6data</doc>')   
    parser_obj.parse(file)             

The result is:

<doc>data</doc><doc>ödata</doc>

Am I passing <type 'string'> or <type 'unicode'>?

Paul


--


************************
*Paul Tremblay         *
*phthenry@earthlink.net*
************************