2011-05-11 77 views
1

我面臨的問題是每當我嘗試使用Ant構建應用程序時,我需要更改strings.xml中的某些值。我通過replacefilter解析的值是一些瑞典民族特徵。但是在buid完成後他們正在改變。如何防止在xml中替換字符時構建更改國家字符

在build.xml中我寫的:

<replace file="res\values\strings.xml"> 
<replacefilter token="@[email protected]" value="${application.name}" /> 

屬性文件中:ånimal

在strings.xml中值 <string name="app_name">@[email protected]</string>

是越來越改爲<string name="app_name">Ã¥nimal</string>

我一直在使用UTF-嘗試8和ISO-8859-1在我的build.xml和strings.xml任何人有任何答案?請幫忙。

回答

1

問題不在於<replace>任務,而是在<property file="..."/>。這是第一次翻譯錯誤的地方。

使用以下代替:

<loadproperties srcFile="application.properties" encoding="utf-8"/> 
+0

感謝,但問題解決了。實際上,構建編碼應該是ISO-8859-1和字符串utf-8,這樣XML解析器就有機會做出正確的翻譯。 – 2011-05-11 14:20:13

+0

早些時候,我在build.xml和strings.xml中都使用了ISO-8859-1。無論如何,感謝Synesso我不知道屬性文件也可以採用這種編碼方式 – 2011-05-11 14:21:02