Ant的复制任务败坏UTF-8个符号 [英] Ant copy task corrupts UTF-8 symbols

查看:191
本文介绍了Ant的复制任务败坏UTF-8个符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的.properties在阿拉伯文译本文件。我用它来取代在HTML文件中的字符串。然而,当我开始复制任务,它彻底破坏的符号和我得到的是这样的:
اÙÙزادات

任何想法是什么造成这一点,我怎么能解决这个问题?

的build.xml

 <目标名称=copyAndReplace>
   <副本todir =...覆盖=是编码=UTF-8>
      <文件集DIR =...包括=* HTML。>< /文件集>
      < filterset>
         <***属性filtersfile文件= />
      < / filterset>
   < /复制>
< /目标与GT;


解决方案

我看到一些可能出现的问题:

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:

  • 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.

  • You should use the outputencoding attribute of copy task. In Windows, UTF-8 is not the default encoding.

这篇关于Ant的复制任务败坏UTF-8个符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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