[Zope] utf-8 vs. unicode question(s)
Tino Wildenhain
tino at wildenhain.de
Fri May 6 17:41:11 EDT 2005
Am Freitag, den 06.05.2005, 19:40 +0200 schrieb Jürgen Herrmann:
> hi out there!
>
> there's been some discussion about utf-8 vs. unicode strings on the
> list lately. i'd like to ask if my gained understandings are correct
> und thus possibly make it clear to others also.
>
> i have set my python default encoding to utf-8, i always send http
> responses from zope as utf-8 (by setting the header like this:
> tal:define="dummy python:request.RESPONSE.\
> setHeader('Content-Type','text/html;; charset=utf-8')"
> )
maybe even better to wrap your template publishing in a
script - this would avoid such a moderate ugly code.
> so if i'd like to use unicode strings in my zope applications, it's
> still necessary to convert request variables to unicode by using
> unicode(REQUEST.foo, 'utf-8'), right?
Yes, or you use :ustring and friends modifier in your forms.
See:
http://www.zope.org/Members/htrd/howto/unicode-zdg-changes
> as far as i understodd, the conversion back to utf-8 is handled
> automagically by zope (if the abovementioned header is set), also
> correct?
Yes if you set the header in response and the body is of
type unicode. If your body is already encoded, you need
to make sure it matches whatever you set in the header.
Regards
Tino
More information about the Zope
mailing list