WittonBell
WittonBell
默认情况下,MSYS的Shell控制台(不管是MINGW还是UCRT64,其它的没测试),虽然在“选项”中设置了本地Locale为`zh_CN.UTF-8`,但是还是使用的与系统一致的代码页进行显示,简体中文为936,并未改为65001,可能这是一个问题。这也是为什么程序中使用了`SetConsoleOutputCP(65001)`后,gdb就基本正常了,但是lldb还是乱码(UCRT64也是),就不知道怎么回事了。 By default, the shell console of MSYS (whether it is MINGW or UCRT64, others are not tested), although the local Locale is set to `zh_CN. UTF-8` in `Options`, but...
Windows控制台的文字显示,与程序内的字符串编码、`setlocale`设置的locale以及[Windows Console的显示代码页](https://learn.microsoft.com/en-us/windows/console/console-code-pages)三方都有关,最好是三者的代码页一致。 用户程序代码内没有使用`setlocale`设置locale,也没有使用`SetConsoleOutputCP`设置Windows Console代码页时,理论上程序应该是使用环境的设置,比如MSYS环境设置的`zh_CN.UTF-8`。 Btw,MinGW的printf输出,最终是一个字节一字节写入到Windows Console的,Win10下正常情况下没问题,不知道在某些特殊情况下会不会出现问题,Win7及之前的版本是肯定有问题的;而Win7下的VS版本没问题,它是调用WriteFile写入到Windows Console的。 MinGW的调用:  代码参见:[https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/stdio/mingw_pformat.c#l402](https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/stdio/mingw_pformat.c#l402) VS的调用:  希望这个线索对修改乱码的BUG有用。
>Are you aware of the fact that setlocale() for native Windows programs do not load locale settings from environment variables? And are you aware of the fact that zh_CN.UTF-8 is...
我使用最新版本的MinGW试了一下,目前gdb和lldb的汉字显示都正常了,lldb调试的程序输出汉字前需要调用SetConsoleOutputCP(65001)就可以正常显示汉字了。 不过gdb的tui显示的源码中汉字还是乱码,调试使用`p`命令显示时,汉字也是乱码。但程序输出,与lldb一样,只要调用了SetConsoleOutputCP(65001)就可以正常显示汉字。另外刚进入tui模式时,字符光标显示有问题,不是在最后一个字符的后面,而是在前面。 I tried using the latest version of MinGW, and currently the Chinese characters displayed in gdb and lldb are normal. Before the lldb debugging program outputs Chinese characters,...