strxfrm works with unicode string ?

nicolas.riesch at genevoise.ch nicolas.riesch at genevoise.ch
Fri Jun 17 04:43:24 EDT 2005


I am trying to use strxfm with unicode strings, but it does not work.
This is what I did:

>>> import locale
>>> s=u'\u00e9'
>>> print s
é
>>> locale.setlocale(locale.LC_ALL, '')
'French_Switzerland.1252'
>>> locale.strxfrm(s)

Traceback (most recent call last):
  File "<pyshell#20>", line 1, in -toplevel-
    locale.strxfrm(s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 0: ordinal not in range(128)
>>>

Someone sees what I did wrong ?




More information about the Python-list mailing list