hm I guess I found an answer myself<br><br>on windows, the default encoding is not 'utf8'<br>thus, if I use<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">encoding =
locale.getlocale()[1]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">t.decode(encoding)</span><br style="font-family: courier new,monospace;">
<br></span>instead of <span style="font-family: courier new,monospace;"><br><br></span><span style="font-family: courier new,monospace;">t.decode('utf8')<br><br></span>it works<span style="font-family: courier new,monospace;">
<br></span><br><div><span class="gmail_quote">On 1/31/07, <b class="gmail_sendername">frank h.</b> <<a href="mailto:frank.hoffsummer@gmail.com">frank.hoffsummer@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all,<br>using python 2.4.4, I have the following session on Mac OS X:<br><br><span style="font-family: courier new,monospace;">import datetime, locale</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
locale.setlocale(locale.LC_ALL, 'se_SE')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">t=datetime.date(2007,01,29).strftime("%A")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">t</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">'M?\xa5ndag'</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">type(t)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><type 'str'></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">t.decode('utf8')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">u'M\xe5ndag'</span><br style="font-family: courier new,monospace;">
<br>fantastic! I just got the unicode version of the swedish name for "Monday"<br><br>now I want to do the same on my PC (also python 2.4.4)<br><br><span style="font-family: courier new,monospace;">import datetime, locale
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">locale.setlocale(locale.LC_ALL, 'swedish')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">t=datetime.date(2007,01,29).strftime("%A")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">t</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">'m\xa5ndag'</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">type(t)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><type 'str'></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">t.decode('utf8')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Traceback (most recent call last):</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "<stdin>", line 1, in ?</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
File "c:\Python24\lib\encodings\utf_8.py", line 16, in decode</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return codecs.utf_8_decode(input, errors, True)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1-3: invalid data</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><br></span>...ups?!?! how can that be? what am I doing wrong? I just don't get it<br>thanks for any insight you might have!!<br><span class="sg">-frank<br><br>
</span></blockquote></div><br>