[ZPT] response.setHeader() best practice

Toby Dickenson tdickenson@geminidataloggers.com
Tue, 09 Apr 2002 15:25:45 +0100


On Tue, 9 Apr 2002 09:45:35 EST5EDT, Alan Kennedy <zpt@xhaus.com>
wrote:

>But the text that the page contains, say news headlines,=20
>must vary in encoding between the two users, otherwise=20
>they'll be looking at gibberish.

It doesnt *have* to vary; you could use an encoding such as UTF-8
which can represent the whole unicode range.

Are you familiar with my Unicode patches, previously at=20
http://www.zope.org/Members/htrd/wstring and now in the Zope CVS ready
for version 2.6?

>So it has to be at publish time.

Yes. The right thing to do in Zope 2.6 will be:

1. Ensure the published method returns a unicode object

2. Set a response header Content-Type: text/html;charset=3DXXXXX

ZPublisher will automatically convert the unicode string into an 8-bit
format using the specified character encoding.

At the moment I dont think ZPT handles Unicode very well. I have said
previously on this list:

> Ive still not actually *used* ZPT, but it seems to make sense for ZPT
> to treat insertion of unicode strings the same way as DTML now does.
> Or, maybe it needs to do something different.... thats why Im asking
> the question here.
>
> Im happy to commit some implementation time to the ZPT side if there
> is agreement about how this should work.


Toby Dickenson
tdickenson@geminidataloggers.com