[Zope] utf-8 vs. unicode question(s)
Andreas Jung
lists at andreas-jung.com
Sat May 7 02:37:18 EDT 2005
--On Freitag, 6. Mai 2005 19:40 Uhr +0200 Jürgen Herrmann
<Juergen.Herrmann at XLhost.de> wrote:
>
> i have set my python default encoding to utf-8, i always send http
> responses from zope as utf-8
My personal point on changing the default encoding of Python: don't do it
(other people
will see this different). As long as you are dealing with really only
*one* encoding it
might be ok. As soon as you mix different encoding (which happens easily
with utf8 and
iso-8859-X) you are doomed at some point within your application because
you will never know
why it some string with some encoding converted to whatever. My strategy if
you need unicode:
keep the default encoding as it is (ascii) and convert everything
internally to Python unicode
string - not to utf8 encoded string. Perform every operation internally
using unicode strings.
Only convert to utf8 on the presentation level (means when you send data
back to the client
or export data to the filesystem or whatever). Such a clean separation
between internal Unicode
representation and external representation saves you a lot of trouble.
-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20050507/cb7f9bba/attachment.bin
More information about the Zope
mailing list