开发者

Messing up of non-typical characters in DOS

A command-line program outputs a list of file paths. I pipe the output to another program to do further processing. It all works fine until a file path is encountered that contains a "strange" character (ó, î, ä, etc.).

The cause of the problem seems to be the behavi开发者_如何学Goor described next:

Test 1

When I execute this command in cmd.exe,

C:\temp> echo ó > o.txt

the contents of the created file will be the character ¢.

Test 2

I created an input file, o_src.txt, (with my text editor) that contains the character ó.

The command

C:\temp> type o_src.txt

will print this character in cmd.exe ¾

If I execute

C:\temp>type o.txt

(o.txt from TEST 1) the result is ó

Test 3

After execution of the command

C:\temp> type o_src.txt > o_dst.txt

then the contents of o_src.txt and o_dst.txt are the same.

How does this work?

ASCII code of ó: F3 / 243

ASCII code of ¢: A2 / 162

ASCII code of ¾: BE / 190


I believe you need to change the code page using CHCP. Look at these questions for more info.

Batch script is not executed if chcp was called

What encoding/code page is cmd.exe using

Unicode characters in Windows command line - how?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜