开发者

Windows XP - cmd.exe - Cannot execute batch file after switching to utf8 codepage

After switching to utf8 codepage with "mode con cp select=65001", batch processing seams to stop working without any error messages.

Thus, executing "cmd.exe /c test.bat" in a freshly started console with codepage 437 or 850 being active works fine. Executing "mode con cp select=65001" works fine. Display of UTF-8-charac开发者_JAVA百科ters works fine. Executing something like "echo Hallo!" works fine.

But executing "cmd.exe /c test.bat" stops working with no error message displayed.

It's not only a display error: The batch file does not get executed.

Switching back to any "old" character set lets it work fine again. Switching forth to UTF8 character set lets it stop working again.

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


I don't know how you can start a batch file after the codepage is changed to 65001.
Even if you save the batch file in utf16-le or utf16-be it doesn't start.

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

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

chcp 65001 & type myFile & chcp 850
echo This also works
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜