[Zope] Odd Unicode error
David Chandek-Stark
dc at duke.edu
Tue Jul 27 18:56:11 EDT 2004
There's also Python's unicode(). I've used it successfully with an
External Method to integrate some external code with a ZPT.
Cheers,
David
Michael Ekstrand wrote:
> 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
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
--
David Chandek-Stark
dc at duke.edu
More information about the Zope
mailing list