Codepage 850 works, 65001 fails! There is NO response to “call foo.cmd”. internal commands work fine

杀马特。学长 韩版系。学妹 提交于 2019-12-01 18:23:53
paxdiablo

Interesting, it's not actually running it at all. If you do the following:

pax> echo echo yy >xx.cmd
pax> chcp 850
pax> xx
yy
pax> chcp 65001
pax> xx
pax> _

you get nothing. It's not just missing output, it's not running at all (as evidenced by putting start . before the echo line). In code page 850, Explorer runs, not so for code page 65001.

There's some discussion on the issue over here. You can get your script to run with:

chcp 65001 && xx.cmd && chcp 850

so it seems to be some sort of problem in starting command files but only when the code page is 65001 before you enter the command!

Others on the net seem to be suggesting that PowerShell may be a good choice, given the finicky support in cmd.exe. That's a decision you'll have to evaluate for yourself but, working in a large organisation myself with many tools to do the same job, I suspect Microsoft will be placing any enhancement efforts behind PowerShell rather the older command shell. Their resources are large but not unlimited.

The cause of this is when cmd.exe for windows xp internally call to the function MultiByteToWideChar using the argument dwFlags with the value 1. The documentation says this: "For UTF-8 dwFlags must be set to 0. Otherwise, the function fails".

A patch for it here: http://consolesoft.com/p/cmd-xp-65001-fix/index.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!