pyexpat and unicode

Brian Quinlan brian at sweetapp.com
Mon Dec 17 17:25:03 EST 2001


Dado wrote:
> data_uni = u"<?xml version='1.0' encoding='UTF-8'
?><hello>\202</hello>"
> data     = "<?xml version='1.0' encoding='UTF-8'
?><hello>there</hello>"
>
> data_uni.encode('utf8')
>
> parser.Parse(data)
> parser.Parse(data_uni)

What effect did you expect the line:

data_uni.encode('utf8')

to have? Unicode objects, like strings, are immutable. What you probably
meant is:

data_uni = data_uni.encode('utf8')

Cheers,
Brian





More information about the Python-list mailing list