Ant 复制任务破坏了 UTF-8 符号 [英] Ant copy task corrupts UTF-8 symbols
问题描述
我有一个带有阿拉伯语翻译的 .properties 文件.我用它来替换 html 文件中的字符串.然而,当我开始复制任务时,它完全破坏了符号,我得到了这样的东西:اÙÙزادات
I have a .properties file with translations in Arabic. I am using it to replace strings in an html file. However, when I start the copy task, it completely corrupts the symbols and I get something like this: اÙÙزادات
知道是什么原因造成的,我该如何解决?
Any idea what's causing this and how I can fix it?
build.xml
<target name="copyAndReplace">
<copy todir="..." overwrite="yes" encoding="UTF-8">
<fileset dir="..." includes="*.html"></fileset>
<filterset>
<filtersfile file="***.properties" />
</filterset>
</copy>
</target>
推荐答案
我看到了一些可能的问题:
I see some possible problems:
在 Java 中,属性 文件假定具有 ISO-8859-1 编码.即使您不直接与 Java 打交道,ant 也会读取属性文件.我在 Vim 和 NetBeans 编辑器中打开属性文件时遇到了这个问题.Vim 将其保存为 UTF-8,NetBeans 保存为 ISO-8859-1.
In Java, Properties files are assumed to have ISO-8859-1 encoding. Even if you're not dealing directly with Java, ant is reading a property file. I've run into this problem when opening a property file in Vim and NetBeans editor. Vim saved it in UTF-8 and NetBeans in ISO-8859-1.
你应该使用<的outputencoding
属性代码>复制代码>任务.在 Windows 中,UTF-8 不是默认编码.
You should use the outputencoding
attribute of copy
task. In Windows, UTF-8 is not the default encoding.
这篇关于Ant 复制任务破坏了 UTF-8 符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!