last day (15 days later) » 

6:02 PM
0
Q: Batch file fails with chcp 65001

Rafael UmbelinoI am finishing up a backup script for my peers to use while at work and I need assistance. We are brazillian and as such, files and paths will be in Portuguese. This means I need Unicode characters like é, á, à, ç and the likes. For example: C:\Users\Usuário\Área de Trabalho is a valid path. ...

 
Does this happen even without a script?
please include screenshots showing the whole thing, especially since your explanation of what is going on is really unclear.
 
Hey barlop, yes, this behaviour of crashing the command prompt happens when I type chcp 65001 either directly or if I put it in a batch and run any command that requires unicode characters like echo é.
 
Forget batch file then. Don't complicate things.. Stay on the simplest way to trigger the problem. You get the error without a batch file so don't talk batch files. Still you included no screenshots. Have you tried from another computer. Type chcp 65001 on another computer's cmd prompt do you see the same problem of it suddenly crashing after typing 'unicode'? (if that's what you're even describing). you shouldn't
 
Hey barlop! I didn't post screenshot because I would have to post a video. Can't take a screenshot of a closed cmd, if you can understand me.
What I meant is that after typing chcp 65001 and pressing enter, the cmd crashs when I try to input any command that includes a unicode character, not the unicode word.
The problem only occurs, and I beg your pardon for that, in Windows 7. Windows 10 works fine.
 
I Have windows 7 I don't have this problem. Have you tried from another computer?
 
6:02 PM
Just tried it on a brand new Windows 7 Pro install. The problem did happen.
Windows 7 Pro SP1 32bits if that info is needed.
 
OK so if you type or copy/paste in eg Á then you hit ENTER, then it closes cmd
What if you hold the window key, and hit R, then the run dialog box comes up. Then you type cmd then hit ENTER. Now if you type your unicode character and hit ENTER does the cmd prompt still close?
And what if you copy/paste echo Á && pause then hit ENTER. Does it disdplay it and say "press any key to continue" or does it instantly close even before you press any key?
 
If I do as you said, everything works alright. But if I use chcp to change the codepage to 65001 prior to that, the problems arise. If I don't change, there's no problems. The thing is that I need unicode support so paths and filenames can be interpreted correctly.
 
chcp 65001 && echo Á && pause <-- So that causes your cmd window to close? If that causes your cmd window to close, maybe there is something in event viewer under applications
administrative tools...event viewer... windows logs..application i.imgur.com/lQgzdb8.png
also try codepage 850 pastebin.com/raw/uUXziBVE that can display many latin characters such as Á
You mentioned codepage 850 but codepage 850 accepts all of é, á, à, ç
 
Default codepage to brazillian Windows is 850. But when executing a batch file, although the default codepage accepts accents, the script ends up messing everything. I can't understand exactly why, though. I'm almost giving up and doing two different scripts, one for Windows 10 and one for Windows 7. I got the Windows 10 part working saving the file with encoding 8859-1 and setting codepage to 28591. The same doesn't work for Windows 7, sadly.
Also, nothing on the event viewer. I also tried to get a log of sorts out of the cmd crashing, but no dice on that front too.
 

last day (15 days later) »