[Zope] Unicode and libxml2

Jens Dobberthin jens.dobberthin at noonox.com
Thu Nov 20 08:57:23 EST 2003


Salut,

I'm using Zope2.6 (Python2.1) and libxml2 and got some trouble with
unicode. I'm parsing a xml document and write out the content of the
nodes with:

def utf_to_latin(content):
  """Converts an string in utf-8 to latin 1."""
  return unicode(content,'utf-8').encode('iso-8859-1')

That works fine, since it prints nice the German "Umlauts". Now I made
some changes via a web form and want to store back the new content. When
I call 

reportDoc.saveFormatFileEnc('-', 'ISO-8859-1', 1)

it fails. Probably because the nodes of the xml tree do not contain
UTF-8 strings. So how to convert the data I've got from the web form
into UTF-8? 

Thanks in advance,
Jens.





More information about the Zope mailing list