[Tutor] local daynames in unicode
frank h.
frank.hoffsummer at gmail.com
Wed Jan 31 21:34:47 CET 2007
Hello all,
using python 2.4.4, I have the following session on Mac OS X:
import datetime, locale
locale.setlocale(locale.LC_ALL, 'se_SE')
t=datetime.date(2007,01,29).strftime("%A")
t
'M?\xa5ndag'
type(t)
<type 'str'>
t.decode('utf8')
u'M\xe5ndag'
fantastic! I just got the unicode version of the swedish name for "Monday"
now I want to do the same on my PC (also python 2.4.4)
import datetime, locale
locale.setlocale(locale.LC_ALL, 'swedish')
t=datetime.date(2007,01,29).strftime("%A")
t
'm\xa5ndag'
type(t)
<type 'str'>
t.decode('utf8')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\Python24\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1-3: invalid
data
...ups?!?! how can that be? what am I doing wrong? I just don't get it
thanks for any insight you might have!!
-frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070131/48dc3e5e/attachment.htm
More information about the Tutor
mailing list