sorting slovak utf
Martin v. Löwis
martin at v.loewis.de
Mon Dec 8 18:40:44 CET 2003
Stano Paska <paska at kios.sk> writes:
> import locale
> locale.setlocale(locale.LC_CTYPE, 'sk_SK.utf-8')
> locale.setlocale(locale.LC_CTYPE, ('sk_SK', 'utf-8'))
> but i got "unsupported locale" error
> What I must do to get correct sorting result?
You don't need to operate in a UTF-8 locale. Instead, any Slovak
locale will do, provided your system offers locale.strcoll for Unicode
objects (try locale.strcoll(u"", u"")).
In this case, you can convert all strings to Unicode, and then collate
Alternatively, you could set the locale to any Slovak locale, and use
locale.getpreferredencoding() to find the locale's encoding. Then you
could convert all input strings to that encoding, and use
locale.strcoll to collate them as byte strings.
More information about the Python-list