Undeterministic strxfrm?

Tuomas tuomas.vesterinen at pp.inet.fi
Tue Sep 4 06:34:54 EDT 2007


Python 2.4.3 (#3, Jun  4 2006, 09:19:30)
[GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import locale
 >>> def key(s):
...     locale.setlocale(locale.LC_COLLATE, 'en_US.utf8')
...     return locale.strxfrm(s.encode('utf8'))
...
 >>> first=key(u'maupassant guy')
 >>> first==key(u'maupassant guy')
False
 >>> first
'\x18\x0c \x1b\x0c\x1e\x1e\x0c\x19\x1f\x12 
$\x01\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x01\xf5\xb79'
 >>> key(u'maupassant guy')
'\x18\x0c \x1b\x0c\x1e\x1e\x0c\x19\x1f\x12 
$\x01\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x01\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x01\xb5'
 >>>

May be this is enough for a sort order but I need to be able to catch 
equals too. Any hints/explanations?



More information about the Python-list mailing list