hm I guess I found an answer myself

on windows, the default encoding is not 'utf8'
thus, if I use

encoding = locale.getlocale()[1]
t.decode(encoding)

instead of

t.decode('utf8')

it works

On 1/31/07, frank h. <[EMAIL PROTECTED]> wrote:

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


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to