Ant encoding problem on Windows - UTF-8 files but spits garbage on diacritics

后端 未结 5 744
我寻月下人不归
我寻月下人不归 2020-12-15 17:38

Somehow I can\'t get my UTF-8 sources to play nice with Ant.

I get a whole lot of \"warning: unmappable character for encoding ascii\". I\'m going crazy, really. Hou

5条回答
  •  忘掉有多难
    2020-12-15 18:24

    To all you who use UTF-8 source files on Windows and was trying to build Android packages with Proguard using the famous blog post by Dan Galpin/Tim Bray.

    This encoding problem happens with javac (thanks for the tip, JesperE). However, I was unable to create a new javac rule on my project's files, because of needed parameters that I didn't know anything about. So here is the easy answer (probably not the only answer):

    1. Try the usual "ant release" command.
    2. Notice that, on the start, there is an output talking about some imported ANT rules. Right on the start you will see some [setup] rules. Look for this one:

      [setup] Importing rules file: tools\ant\ant_rules_r3.xml

    3. Find that file and open it. Search for "javac encoding". You will see that is set to "ascii". Change to "UTF-8".

    4. Do the "ant release" again and it will be fine.

    That's how I did here. I'm sure there is a way to override this on a per-project basis. But it kept giving me errors on mandatory parameters, as I said. So for me at least it was that much easier doing this way. Besides, I only work with UTF-8 anyway.

提交回复
热议问题