Codepage 850 works, 65001 fails! There is no response to "call foo.cmd". internal commands work fine

The question basically explains the problem.

I am using Windows XP Pro Service Pack 3
COMSPEC = C: \ WINDOWS \ system32 \ cmd.exe
I started the console through Start ... Run-dialog ... cmd.exe

Here is the "view" of my console:
Command, then output (and my // comments)

C:\> chcp 850 Active code page: 850 // output is as expected C:\> echo @chcp ^& REM 850>test850.cmd // no output; as ecpected) C:\> type test850.cmd @chcp & REM 850 // output is as expected C:\> call test850.cmd Active code page: 850 // output is as expected 

The above works fine (as expected). Things are happy in Windows-land, but the โ€œcallโ€ is FAILS when I switch to code page 65001

 C:\> chcp 65001 Active code page: 65001 // output is as expected C:\> echo @chcp ^& REM 65001>test65001.cmd // no output; as ecpected C:\> type test65001.cmd @chcp & REM 65001 // output is as expected C:\> call test65001.cmd // NO OUTPUT, NO ERROR, NO ANYTHING, NADA... other than frustration :) 

What is happening (NOT happening) here?

+4
source share
2 answers

Interestingly, this does not work 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> _ 

nothing happens. This is not just the lack of output, it does not work at all (as evidenced by the placement of start . To the echo line). On the code page 850 Explorer works, not for code page 65001.

The question is discussed here . You can run the script with:

 chcp 65001 && xx.cmd && chcp 850 

so this seems to be some kind of problem when running batch files, but only when the code page is 65001 before entering the command!

Others on the net seem to suggest that PowerShell might be a good choice, given the lackluster support in cmd.exe . This is a solution that you will need to evaluate on your own, but, working in a large organization with many tools to do the same job, I suspect that Microsoft will pay more attention to PowerShell over the older command shell. Their resources are large, but not unlimited.

+3
source

The reason for this is that cmd.exe for Windows xp internally calls the MultiByteToWideChar function using the dwFlags argument with a value of 1. The documentation says: "For UTF-8, dwFlags must be set to 0. Otherwise, the function does not work."

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

+1
source

All Articles