Windows XP - cmd.exe - Unable to execute batch file after switching to utf8 code page

After going to utf8 code page with "mode con cp select = 65001", batch processing packets will stop working without error messages.

Thus, running "cmd.exe / c test.bat" on a recently launched console with an active code page of 437 or 850 works fine. Doing "mode con cp select = 65001" works fine. UTF-8 character mapping works great. Doing something like "Hallo echo!" works great.

But running "cmd.exe / c test.bat" stops working without displaying an error message.

This is not only a display error: the batch file is not executed.

Switching to any "old" character set allows you to work again. Switching to the UTF8 character set allows it to stop working again.

Of course, abstaining from UTF8 is a solution, but with bad side effects in the background.

+3
source share
1 answer

I do not know how you can run the batch file after changing the code page to 65001.
Even if you save the batch file to utf16-le or utf16-be, it will not start.

But you can run the batch file and change the code page inside,
but it is important that the rest of the code is cached in a block (brackets or ampersand).

@echo off
(
chcp 65001
rem Do my UTF work
chcp 850
)
echo This works

chcp 65001 & type myFile & chcp 850
echo This also works
+4
source

Source: https://habr.com/ru/post/1789658/


All Articles