Re: [xml] python, xml, utf8->iso-8859-2 problem



Hannu Krosing kirjutas T, 18.02.2003 kell 19:19:
Pavel Stehule kirjutas T, 18.02.2003 kell 10:17:
On Mon, 17 Feb 2003, Daniel Veillard wrote:

On Mon, Feb 17, 2003 at 08:09:09PM +0100, Pavel Stehule wrote:
element.newChild(None,"beta","¾lutý kùò")

try:
element.newChild(None,"beta",u"¾lutý kùò".encode('utf-8'))

btw, the sitecustomize.py-independant version would be

element.newChild(None,"beta",unicode("¾lutýkùò","iso-8859-2").encode('utf-8'))

so yout automatic conversion from sitecustomize.py makes the u"xxx" part
convert from iso-8859-2 to pythons internal unicode UCS-2 (or UCS-4) and
the encode('utf-8') part makes libxml2 happy by giving it a
non-python-unicode 8-byte utf-8 string ;)



_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml



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