[issue41821] Printing specific Unicode characters causes unwanted beeping in Windows 7 console

Eryk Sun report at bugs.python.org
Sun Sep 20 18:05:16 EDT 2020


Eryk Sun <eryksun at gmail.com> added the comment:

> It is set to use an OEM raster font.

Okay, then the issue can either be closed as third-party or changed to a documentation enhancement. It could be documented that Unicode support requires selecting a TrueType font in the console properties. "Raster Fonts" uses OEM with a lossy best-fit conversion (e.g. "α" -> "a").  

> So I assume that with the UTF-8 flag set the font still has to be 
> set to a TTF-Font so it does not beep?

Yes, the conversion to OEM for "Raster Fonts" occurs in the console itself. 

> I CP850 required to encode those characters via CP850 to the 
> bell character?

Other OEM codepages have a different best-fit mapping. For example, codepage 437 maps U+2022 to ASCII bell, but not U+2024 or U+2219.

> I was a bit lost on what happens under the hood encoding-wise as 
> sys.stdout.encoding just returns 'utf-8'.

For a console file, the io module uses io._WindowsConsoleIO for the raw layer instead of io.FileIO. _WindowsConsoleIO internally uses the console's wide-character (UTF-16) API and converts to and from UTF-8. 

Overriding the standard I/O encoding to UTF-8 isn't needed for _WindowsConsoleIO. It's needed for regular files and pipes when standard I/O is redirected, since those still default to the process active codepage (usually system ANSI).

----------

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


More information about the Python-bugs-list mailing list