[ZPT] response.setHeader() best practice

Alan Kennedy zpt@xhaus.com
Tue, 9 Apr 2002 10:41:38 EST5EDT


I'm not trying to extend this thread ad nauseam, and I'm 
not picking holes for its own sake. But I do believe this 
is an important topic, and one which we should perhaps 
thrash out now, while we're on the subject....

[Alan]

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

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

Agreed. But using Unicode is not an optimal solution because

1. UTF-8 is culturally biased towards western languages
2. UTF-16 is wasteful of bandwidth if you're only using < 
200 characters out of the 64K range (unless you're using 
compression, but that's another issue) 
 
[Toby wrote]

> 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=XXXXX
> 
> ZPublisher will automatically convert the unicode string
> into an 8-bit format 

That's clever, (and potentially resource-costly?)

> using the specified character encoding.

Ah, we've gone full-circle. Where is that character 
encoding specified?

Alan Kennedy.



---------------------------------------------
This message was sent using WebMail by CyberGate.
http://www.gate.net/webmail