sorting slovak utf

Stano Paska paska at kios.sk
Mon Dec 8 12:06:20 CET 2003


Hi,

I have one problem.
In file aaa.txt I have slovak letters in utf-8.

zcaron
scaron
aacute
ocircumflex
tcaron
yacute
ccaron
eacute
lcaron
iacute
dcaron
uacute
adiaeresis
oacute
lacute
ncaron
racute

with this script (output is redirected to file bbb.txt):

import fileinput
riadky = []
a = fileinput.input("aaa.txt")
for i in a:
     riadky.append(i.strip())
a.close()
riadky.sort()
for i in riadky:
     print i

I have this result:

aacute
adiaeresis
eacute
iacute
oacute
ocircumflex
uacute
yacute
ccaron
dcaron
lacute
lcaron
ncaron
racute
scaron
tcaron
zcaron

and corrent result would be:

aacute
adiaeresis
ccaron
dcaron
eacute
iacute
lacute
lcaron
ncaron
oacute
ocircumflex
racute
scaron
tcaron
uacute
yacute
zcaron

I have set utf-8 in sitecustomize.py

I tried:
import locale
locale.setlocale(locale.LC_CTYPE, 'sk_SK.utf-8')
and
locale.setlocale(locale.LC_CTYPE, ('sk_SK', 'utf-8'))
but i got "unsupported locale" error

What I must do to get correct sorting result?

Stano.

P.S. lower, upper works correct









More information about the Python-list mailing list