Interpreting non-ascii characters.

ddtl this at is.invalid
Tue Jul 17 20:11:27 CEST 2007


Hello everybody,

I want to create a script which reads files in a
current directory and renames them according to some
scheme. The file names are in Russian - sometimes 
the names encoded as win-1251, sometimes as koi8-r etc. 
I want to read in file name and convert it to list for 
further processing. The problem is that Python treats 
non-ascii characters as multibyte characters - for 
example, hex code for "Small Character A" in koi8-r is 
0xc1, but Python interprets it as a sequence of 
\xd0, \xb1 bytes.

What can I do so that Python interprets non-ascii 
characters correctly?





More information about the Python-list mailing list