[XML-SIG] problems reading iso-8859-1 data
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Mon, 30 Apr 2001 20:39:55 +0200
> > Yes, I have the encoding="iso-8859-1" set the file. It sounds as if
> > expat is converting the iso-8859-1 to UTF-8. Is there a way to convert
> > back to iso-8859-1? Unfortunately, I'm stuck with 1.5.2.
>
>
> Try this :
>
> ---------------------------8<---------------------------------
> from xml.unicode.utf8_iso import utf8_to_code, code_to_utf8
> import cStringIO
Or, shorter yet:
from xml.unicode.iso8859 import wstring
def utf8_to_latin1(s):
wstring.decode("utf-8",s).encode("iso-8859-1")
def latin1_to_utf8(s):
wstring.decode("iso-8859-1",s).encode("utf-8")
Regards,
Martin