john_miller <johnson.b.ourne+pythonbugtrac...@gmail.com> added the comment:
It is set to use an OEM raster font. (Should the information about the font and possible unwanted beeping be mentioned on https://docs.python.org/3/using/windows.html ? Perhaps even a short link regarding "Windows issues" under the print()-entry?) Thanks for your help. I was a bit lost on what happens under the hood encoding-wise as sys.stdout.encoding just returns 'utf-8'. I CP850 required to encode those characters via CP850 to the bell character? I'm not clear on how setting Python to use UTF-8 interacts with the regular console. Basically there are two different basic fixes for printing various text without beeping to the console as-is (with the font set to the default setting raster font): 1. Set the font to a TTF-Font in the console settings 2. Filter or replace the offending Unicode characters (\u2022, \u2024, \u2219) in the Unicode string before printing it to "sys.stdout". In the case where the UTF-8 flag is set (Environment variable set PYTHONUTF8=1 or "python.exe -X utf8 script.py" called within the console), it seems that it still beeps. In interactive mode and when entering the command in the console. Both these cases still beep. python.exe -X utf8 -c "print('\u2022')" set /A PYTHONUTF8=1 & python.exe -c "print('\u2022')" & set PYTHONUTF8= Using python.exe from the explorer without opening it from a console Window (that was opened via cmd.exe) also beeps. 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? ---- As for redirecting STDOUT in the console, the UTF-8 option seems to be sufficient, simply printing the character utf-8 encoded into the file: python.exe -X utf8 -c "print('\u2023')" >> testfile.txt A quick test for writing bytes to a file this way (see also Issue4571): python.exe -X utf8 -c "import sys; sys.stdout.buffer.raw.write(b'\x20\x20a')" >> testfile.txt ) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41821> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com