python and unicode problem

Martin Kirst <[email protected]> Tue, 02 Nov 2004 01:14:32 +0100
Newsgroups gmane.comp.gnome.lib.xml.bindings
Message-ID <[email protected]>
Hello

I'm coding a tool in python, which uses a lot of unicode strings.
I want to switch to libxml2.

What about the unicode support in libxml2 wrappers for python?

I've tested some pieces of code, but they don't work ...

t='<? xml .... some valid xml stuff with german special characters'
ut = unicode(t,'latin-1')
newdoc = libxml2.parseMemory(ut,len(ut))

Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.3/site-packages/libxml2.py", line 1174, in 
parseMemory
     ret = libxml2mod.xmlParseMemory(buffer, size)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in 
position 107: ordinal not in range(128)

Whats the problem?

Thanks & Bye
  Martin