Windows批处理中的Echo UTF-8字符 [英] Echo UTF-8 characters in windows batch

查看:674
本文介绍了Windows批处理中的Echo UTF-8字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用echo生成UTF-8文本文件吗? 例如,如果我要生成一个包含字符ę"的文件

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

(批处理文件使用UTF-8编码)

(the batch file is encoded with UTF-8)

结果是ANSI编码的文件,并且ę"字符转换为ê". 如何说服"echo"生成UTF-8文件?

the result is an ANSI encoded file and the "ę" character is transformed into "ê". How can I convince "echo" to generate an UTF-8 file?

如果不可能,那么创建文本文件后可以更改其编码吗? gnuwin32软件包中是否有任何工具可以帮助我更改编码?

If it's not possible, then can I change the encoding of the text file after creating it? Is there any tool in the gnuwin32 package that can help me to change the encoding?

谢谢

推荐答案

问题是文件包含以下行:

The problem was that the file contained the line:

<META content="text/html; charset=iso-8859-2" http-equiv=Content-Type> 

,然后Notepad2和Firefox更改了字符集,显示Ä而不是ę.在普通记事本中,文件看起来正常. 解决方案是在文件开头添加UTF-8签名(字节顺序标记):

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来自gnuwin32)

(echo1 is from gnuwin32)

感谢您的回答

这篇关于Windows批处理中的Echo UTF-8字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆