[z3-five] unicodes and strings in Zope 2.9's ZPT with Zope 3's i18n

Martijn Faassen faassen at infrae.com
Tue Jul 25 13:13:52 CEST 2006


Chris Withers wrote:
> Philipp von Weitershausen wrote:
>> Yes. In an ideal case (read: Zope 3), the application returns text as
>> unicode and never has to bother with strings. The publisher will
>> negotiate the best encoding with the browser and send 8 bits over the wire.
> 
> Indeed.
> 
>>> In my case, I was inserting the utf-8 encoded title of a document into a 
>>> generated navigator...
>> I see. When in doubt, just make sure that anything ending up in a ZPT is
>> unicode. Of course, ideally, those document titles would be stored not
>> in UTF-8 but in unicode...
> 
> Hurm, I see a world of pain for Zope 2 going forward :-/

It is a world of pain indeed - Infrae has been dealing with this world 
of pain for years now as Silva *is* one of the few appications in Zope 2 
that behaves well for unicode. PlacelessTranslationService, which has 
extremely nasty workarounds to allow users to combine encoded strings 
with unicode strings was hurting us, as it introduced subtle bugs in 
previously well-behaved code.

What the right way should be for existing Zope 2 applications I do not 
know.

For *new* Zope 2 applications, my strong recommendation would be to 
store human-readable text as unicode, and if your text is stored 
externally (file, rdb), to decode it into unicode as soon as possible 
when it enters your application.

Regards,

Martijn


More information about the z3-five mailing list