[Zope3-dev] Unicode handling in Zope3 Page Templates

Martijn Faassen faassen at infrae.com
Tue Aug 31 04:40:22 EDT 2004


Sidnei da Silva wrote:
[snip]
> If I use sys.setdefaultencoding('utf-8') in sitecustomize.py, I get a
> bit further, but then when the special char is displayed, I get a '?'
> char instead. 

I'll just reiterate again (I already said it in private to you but can't 
hurt to say it in public) that doing site.setdefaultencoding is plain 
evil. It destroys any hope of compatibility and may well disrupt the 
workings of some code that catches unicode errors and expects them when 
a piece of text is non-ascii.

No code should depend on this. You're not entirely clear in the 
following text that *aren't* depending on this.

> From poking around, It seems like what's happening is that ZPT is
> getting a 'latin-1' encoded string, and converting to unicode using
> 'utf-8', which is the system default encoding.
> 
> I've made some changes to tales, tal and pagetemplate and added a test
> to confirm that if only encoded strings are returned it doesn't
> break. And if only unicode strings are returned it also doesn't break.

Which has nothing to do with system default encoding, to make this 
entirely clear.

Regards,

Martijn


More information about the Zope3-dev mailing list