On GitHub, there are many codes using
chcp 65001. This is hack to display UTF-8 on Windows command prompt. Probably, this hack may works well on non multi-byte locales. But this doesn't work correctly on multi-byte locales. For example, jq used this hack. https://github.com/stedolan/jq/pull/824
This hack break Windows command prompt on multi-byte users.
You can see the font is changed and not restored.
On East Asian locale, figure of backslash is not same on non East Asian locale. On non East Asian locale, backslash is displayed like below.
But on East Asian locale, backslash are displayed like following.
FYI, Most of Windows users normally uses non UTF-8 codepage. For example, japanese use codepage 932.
I wrote a patch to fixed this. https://github.com/stedolan/jq/issues/1121
Furthermore, curl used this hack. https://github.com/curl/curl/issues/3008
This also break cmd.exe.
I wrote a patch similar above again. https://github.com/curl/curl/pull/3212
As I wrote on the description of this PR, when changing codepage on Windows console modify font to suitable possibly. And restoring codepage also set suitable font. So original font is not restored correctly. To write UTF-8 without changing console codepage, you should use Wide String APIs.
Please stop to use hack
If you want to run batch file written in UTF-8, you should run with below to avoid breaking command prompt:
start /wait /min foo.bat
(open source and trusted by devs everywhere ❤️)