Batch : encoding hell
In DOS batch, I have to read file paths from a file encoded in UTF-8.
chcp 65001
:: read my file...
Now all messages displayed in my script are broken (accentuated characters appear wrong). So I guess I must revert to the 开发者_Go百科previous chcp
value.
When I call chcp all by itself, it spits me a nasty line, while all I want is the number :
C:...>chcp
Page de codes active : 850
How can I save the current codepage value in a variable before changing, so that I can set back to it after having read my file, and thus have my messages displayed in the console appear fine ?
for /f "tokens=2 delims=:" %a in ('chcp') do set OLDCP=%a
set OLDCP=%OLDCP:~1%
The second line removes the space before the number. Not actually needed, but I try keeping my values clean.
精彩评论