[Zope-xml] Trouble with ParsedXml and ISO-8859-1 char set

Martijn Faassen faassen at vet.uu.nl
Fri Feb 15 11:08:38 EST 2002


Jordi Saludes Closa wrote:
> > I have trouble using xml-files which contain data
> > with special character from Latin-1 (German Umlaute).
> >
> > Everything works fine as long as I don't use special
> > German characters from ISO-8859-1 the char. Then I get
> > an UnicodeError. Although I use the encoding="ISO-8859-1"
> > attribute in the xml-header.
> >
> > Is there any other way of putting xml-data in a ParsedXml
> > object using dtml-calls?
> 
> I had the same problem when using "Upload File" in the Edit tab of ParsedXML, 
> but now it goes ok. Check the following:
> 
> In python do:
> 
> >>> import site
> >>> site.encoding
> 
> if it is not 'ISO8859-1' but 'ascii' you should activate the use of locale 
> encodings at the file 'site.py' in your python library.
> In the following fragment, change 'if 0:' to 'if 1:'
> 
> encoding = "ascii" # Default value set by _PyUnicode_Init()
> 
> if 0:
>     # Enable to support locale aware default string encodings.
>     import locale
>     loc = locale.getdefaultlocale()
>     if loc[1]:
>         encoding = loc[1]
> 
> 
> Hope this works!

Hm, this is interesting, but I suspect ParsedXML is still buggy in this
regard even so.. If people can help me with Python unicode issues to
figure out what's going wrong I'd appreciate it though. I suspect
ExtraDOM.writeStream is involved, which has an encoding argument. It's called
from ManageableDOM in several places, so perhaps you need to look there.
The DOM has some way to find out encoding that I cannot recall currently. :)

Anyway, that should be enough to get some of you started, and I'd much
appreciate patches. I run into that unicode error issue myself sometimes.
(can add non-ascii programmatically, but then cannot view it in the browser)

Regards,

Martijn





More information about the Zope-xml mailing list