[ZPT] Re: Fix for UnicodeError: ASCII decoding error: ordinal not in range(128)

Florent Guillaume fg@nuxeo.com
03 Feb 2003 01:00:09 +0100


Hi,

I've released TranslationService 0.3. It should fix the problems people
encountered when working with Localizer 1.0.0 and earlier.

The rules are:

- Don't use LOCALIZER_USE_ZOPE_UNICODE, because ZPT's Unicode treatment
  is too broken to be easily patched.

- If you use any non-ASCII chars directly in you ZPT's, then they must
  be encoded in the output encoding of the ZPT, which defaults to
  latin1.

- If you need a different output encoding, for instance UTF-8, set it
  with:
  <tal:block define="x python:request.RESPONSE.setHeader('Content-Type',
                    'text/html;;charset=UTF-8')" />
  at the top of the ZPT (Plone already does this).

- Don't use sys.setdefaultencoding() unless you know what you do. If you
  set it to something else than the output encoding of the ZPT, you're
  likely to see weird things.

I hope this really works for you now.

In the future, I plan on reworking all of ZPT's Unicode behavior but it
means many changes and I don't have the time right now.

Thanks for your comments.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com