[Zope] Odd Unicode error
Michael Ekstrand
michael-zope at elehack.net
Mon Jul 26 17:16:30 EDT 2004
I'm getting some odd Unicode errors in the Zope application I'm
developing.
The application has an Edit page which uses HTMLArea to provide a
WYSIWYG interface to editing an HTML snippet. This snippet is then
saved, and a Page Template reads it and inserts its contents when the
page is viewed.
Sometimes, after editing and saving a page, when I view it, I get a
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position
<some position>: ordinal not in range(128).
As near as I can tell, it's evidently receiving an invalid value from
the form. If I load the content in the management interface (where it's
displayed with a plain text area), and save it, the error goes away,
but usually comes back the next time it's edited with the general edit
page (with the HTMLArea).
What can be done about this error? Is there a way I can scrub the data
when I save it to force it to be valid? I've thought about using
content.replace('0xa0', ' ')
since it seems to be always 0xa0 that's causing the problem (and
consulting a Unicode table revealed that 0xa0 is some form of space
character), but I don't know if this is a complete enough solution.
TIA,
-Michael
More information about the Zope
mailing list