[Python-3000] locale-aware strings ?

"Martin v. Löwis" martin at v.loewis.de
Wed Sep 13 06:44:54 CEST 2006


Fredrik Lundh schrieb:
> today's Python supports "locale aware" 8-bit strings; e.g.
> 
>     >>> import locale
>     >>> "åäö".isalpha()
>     False
>     >>> locale.setlocale(locale.LC_ALL, "sv_SE")
>     'sv_SE'
>     >>> "åäö".isalpha()
>     True
> 
> to what extent should this be supported by Python 3000 ?

I would like to see locale-aware operations, but with an
explicit locale, e.g.

import locale
l = locale.load(locale.LC_ALL, "sv_SE")
print l.isalpha("åäö")

(i.e. character properties become locale methods,
not string methods).

To implement that, we would have to incorporate ICU,
which would be a tough decision to make (or have our own
implementation based on the tables that ICU uses).

Alternatively, we could try to get such locale objects
from system APIs where available (e.g. <xlocale.h>
in glibc), and not provide them on systems that don't
have locale objects in their APIs.

Regards,
Martin


More information about the Python-3000 mailing list