Echo UTF-8 characters in windows batch

后端 未结 5 1816
暖寄归人
暖寄归人 2021-02-03 22:41

Can I use echo to generate an UTF-8 text file? For example if I want to generate a file that contains the character \"ę\"

echo \"abcd ę\" > out.txt

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-03 22:46

    The problem was that the file contained the line:

     
    

    and then Notepad2 and Firefox was changing the charset, showing Ä instead of ę. In plain Notepad, the file looks ok. The solution was to add the UTF-8 signature (Byte Order Mark) at the beginning of the file:

    echo1 -ne \xEF\xBB\xBF > out.htm
    

    (echo1 is from gnuwin32)

    thanks for the answers

提交回复
热议问题