I had A LOT of similar problems when I need to work with cyrillic. I
can easily replay your problem. Fortunately I'm on localized Windows
machine.
So:
>>> path = r'C:\Documents and Settings\vanilla'
>>> os.path.isdir(path)
True
>>> os.listdir(path)[-1]
'\xd8\xe0\xe1\xeb\xee\xed\xfb'
>>> a = os.listdir(path)[-1]
>>> a
'\xd8\xe0\xe1\xeb\xee\xed\xfb'
>>> a.decode('utf-8')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python25\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 0-1:
invalid dat
a

Here it is! Extremely difficult to diagnose problem!

And let's fix it:
>>> import sys
>>> a.decode(sys.getfilesystemencoding())
u'\u0428\u0430\u0431\u043b\u043e\u043d\u044b'
>>> b = a.decode(sys.getfilesystemencoding())
>>> print b
Шаблоны
>>> c = b.encode('utf-8')

Fixed

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to