Python: release some Utf-8 line to Windows console

Possible duplicate:
Python, Unicode and Windows console

I read several lines from a file, and when I try to print these utf-8 lines in the Windows console, I get an error

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128)

I tried to install console encoding in utf-8 with "chcp 65001" But what am I than getting this error message

LookupError: unknown encoding: cp65001
+5
source share
2 answers

I recommend that you check for similar questions in stackoverflow, there are many of them.

In any case, you can do it like this:

  • read from a file in any encoding (for example, utf8), but decode strings in unicode
  • Windows, unicode. . , .

.

+3

print Unicode , . :

>>> import sys
>>> sys.stdout.encoding
'cp852'

, ( Python). , .

+1

All Articles