[xml-bindings] python and unicode problem


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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]