开发者

encoding issue with special chars in properties file

I have a ant build script that uses a build.properties file. There I have something like this:

release_type=debug
version_code=1
version_name=1.0.0
logo_text=This is German: special chars like ä or ö

My problem is now, that I use logo_text to replace a placeholder in an xml file and the result is in 2 of 3 builds garbage like:

<string name="logo_text">"This is German: special chars like ää or ü."</string>

I have 3 build targets (each using their own properties file) and its always the same 2 get the mess up, the 开发者_StackOverflow中文版third one is correctly replaced.

The source of the text is always a build.properties which is UTF-8 encoded and the build file uses UTF-8, too. I can't find any difference why the two have this issue.

How I replace the placeholder with the text:

<?xml version="1.0" encoding="UTF-8"?>
<project name="branding-builds">
    <!-- code snipped -->
    <copy todir="./${short_title}">
        <fileset dir="./brandings/${short_title}">
            <exclude name="**/*.png"/>
            <exclude name="**/*.java"/>
        </fileset>
        <filterset>
            <filter token="LOGO_TEXT" value="${logo_text}" />
        </filterset>
    </copy>
    <!-- code snipped -->
</project>

Info: Rewriting the special chars to make sure that copy&paste didn't messed up didn't solve the issue.


A properties file should't be UTF-8 encoded. Quote from http://download.oracle.com/javase/6/docs/api/java/util/Properties.html:

the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes ; only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜