pyexpat and unicode

mallum breakfast at
Mon Dec 17 11:17:00 EST 2001

Hi all;

I may be doing something stupid here and missing the obvious, but if I
run the following;


import xml.parsers.expat
parser = xml.parsers.expat.ParserCreate(encoding='utf8')

data_uni = u"<?xml version='1.0' encoding='UTF-8' ?><hello>\202</hello>"
data     = "<?xml version='1.0' encoding='UTF-8' ?><hello>there</hello>"




expat barfs with ;

Traceback (most recent call last):
  File "./", line 12, in ?
UnicodeError: ASCII encoding error: ordinal not in range(128)

Does this mean Im unable to pass utf8 encoded strings to pyexpat ?
According to the docs it should. Can anyone spread some light on this.

  -- mallum

More information about the Python-list mailing list