Eryk Sun <eryk...@gmail.com> added the comment:

> PS> [System.Console]::OutputEncoding

The console's current output encoding is irrelevant to this problem.

In Windows, pydoc uses the old "more.com" pager with a temporary file that's 
encoded with the default encoding, which is the process active codepage (i.e. 
"ansi" or "mbcs"), unless UTF-8 mode is enabled. The "more.com" utility, 
however, decodes the file using the console's current input codepage from 
GetConsoleCP(), and then it writes the decoded text via wide-character 
WriteConsoleW(). 

The only supported way to query the latter in the standard library is via 
os.device_encoding(0), and that's only if stdin isn't redirected to a file or 
pipe. Alternatively, ctypes can be used via 
ctypes.WinDLL('kernel32').GetConsoleCP(). For the latter, we would need to add 
_winapi.GetConsoleCP(), since using ctypes is discouraged.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44275>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to