[Zope] How to convert Zope instance charset?

Andreas Jung lists at andreas-jung.com
Sun Apr 24 10:22:10 EDT 2005



--On Sonntag, 24. April 2005 16:03 Uhr +0200 Daniel Dekany 
<ddekany at freemail.hu> wrote:

> Sunday, April 24, 2005, 2:36:24 PM, Andreas Jung wrote:
>
>> --On Sonntag, 24. April 2005 14:18 Uhr +0200 Daniel Dekany
>> <ddekany at freemail.hu> wrote:
>>
>>> I have a Zope instance that uses utf-8 for everything. Since
>>> Python/Zope/etc practically doesn't support utf-8,
>>
>> Please explain in which sense Zope would not support utf-8. For your
>> information:
>
> It can't sort strings alphabetically *anywhere* (concretely: the
> accented letters will go to the end of the list -- I guess because 0x80
> is mathematically greater than the code of the US-ASCII characters).

This is neither a problem of Zope nor of Python! A Python string has no
notion an an encoding. The sort method can not smell the encoding. Instead
use Python unicode strings and depend on the sorting order defined by
the Unicode standard. This is an application-level problem but not a
server-side problem.

>
>> Plone has UTF8 as default charset.
>
> Believe me, I really hope I'm wrong. So how could I achieve that strings
> are sorted correctly? If it works for someone, how? (I have locale
> hu_HU.UTF-8 in zope.conf, I have even printed
> locale.getlocale(locale.LC_COLLATE) from products and external methods,
> and it was hu_HU.UTF-8. Note that at least on Python level sorting with
> hu_HU.ISO-8859-2 works... so I hope it would work with Plone as well.)
>

see above..Also the standard sort() methods of Python does not care about 
your
locales (why should it)....strings are streams of bytes...nothing else...
sort() accepts a user-defined comparison method of implement user-specific
sorting. And there are also methods in Python "locale" module to perform
locale-dependent comparison.

Once again: you must solve your problem on the application layer...Zope does
not help you at this point because it can't.

-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/20050424/a74e00d6/attachment.bin


More information about the Zope mailing list