[issue42707] Python uses ANSI CP for stdio on Windows console instead of using console or OEM CP

Inada Naoki report at bugs.python.org
Tue Dec 22 18:32:20 EST 2020


Inada Naoki <songofacandy at gmail.com> added the comment:

I think using Console codepage for stdio is better. But I am afraid about breaking existing code.
How about treating only UTF-8 and leave legacy environment as-is?

* When GetConsoleCP() returns CP_UTF8, use UTF-8 for stdin. Otherwise, use ANSI.
* When GetConsoleOutputCP() returns CP_UTF8, use UTF-8 for stdout. Otherwise, use ANSI.

This will work nice with PowerShell or cmd with `chcp 65001` in most simple cases.

----------
nosy: +methane

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42707>
_______________________________________


More information about the Python-bugs-list mailing list