[ZPT] Unicode support in ZPT

Toby Dickenson tdickenson@geminidataloggers.com
Thu, 25 Apr 2002 11:33:51 +0100


On Thu, 25 Apr 2002 12:14:15 +0200, Godefroid Chapelle
<gotcha@swing.be> wrote:

>The test I have done give me the feeling that Unicode is not supported.

Correct

I have recently comitted changes to give good support in the rest of
Zope; in DTML, ZPublisher, and ZServer. Almost everywhere except ZPT!

>I really need it to support Unicode and am voluntering to work on it if =
I=20
>am able to.

I have never worked with ZPT, which is why my changes didnt extend
that far. It would be nice if ZPT supported the equivalent unicode
semantics as DTML. 'equivalent' may not mean 'identical'; I have been
waiting for a Unicode-aware ZPT expert (such as you ;-) to help
determine that.

DTML now supports the following semantics:

1. If all of its inputs are plain strings, the output is a plain
string. This is a requirement for backwards compatability in DTML, I
am not sure to what extent this is needed for ZPT.

2. If any inputs are mixed plain strings and unicode strings, the
output is a unicode string with the plain string elements converted to
unicode assuming they are latin-1


In the implementation, you may want to use these two utility
functions:

>>> from DocumentTemplate.DT_Util import ustr
>>> print ustr.__doc__
convert an object to a plain string or unicode string

>>> from DocumentTemplate.DT_Util import join_unicode
>>> print join_unicode.__doc__
join a list of plain strings into a single plain string, a list of
unicode strings into a single unicode strings, or a list containing a
mix into a single unicode string with the plain strings converted from
latin-1



Toby Dickenson
tdickenson@geminidataloggers.com