Message 88077 - Python tracker (original) (raw)
an immediate thing to do is to declare cp65001 as an encoding:
Index: Lib/encodings/aliases.py
--- Lib/encodings/aliases.py (revision 72757) +++ Lib/encodings/aliases.py (working copy) @@ -511,6 +511,7 @@ 'utf8' : 'utf_8', 'utf8_ucs2' : 'utf_8', 'utf8_ucs4' : 'utf_8',
'cp65001' : 'utf_8',
uu_codec codec
#'uu' : 'uu_codec',
This is not enough unfortunately, because the win32 API function WriteFile() returns the number of characters written, not the number of (utf8) bytes:
print("\u0124\u0102" + 'abc') ĤĂabc c [44420 refs]
Additionally, there is a bug in the ReadFile, which returns an empty string (and no error) when a non-ascii character is entered, which is the behavior of an EOF condition...
Maybe the solution is to use the win32 console API directly...