Windows 上的 Ant 编码问题 - UTF-8 文件但在变音符号上吐出垃圾 [英] Ant encoding problem on Windows - UTF-8 files but spits garbage on diacritics

查看:31
本文介绍了Windows 上的 Ant 编码问题 - UTF-8 文件但在变音符号上吐出垃圾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知何故,我无法让我的 UTF-8 源代码与 Ant 配合得很好.

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

我收到了很多警告:编码 ascii 的不可映射字符".我快疯了,真的.小时和小时和小时.顺便说一句,我注意到 5 个人已经疯狂地使用了这个标签.:-)

I get a whole lot of "warning: unmappable character for encoding ascii". I'm going crazy, really. Hours and hours and hours. Btw, I noticed 5 people already used the tag crazy. :-)

是的,我已经阅读了 这个this 和其他.谷歌也是(至少 3 或 4 个不同搜索的前 5 页结果,至少).有 javac 选项.我试过了.还有一些预设什么的(对不起,凌晨3点).也没有用.

And yes, I've read this, this and others. Google also (the first 5 page results of at least 3 or 4 different searches, at least). There are javac options. I've tried. There is also some preset or something (sorry, 3 AM). Didn't work either.

我正在使用 Ant 生成 Android apk 文件.我不能使用 Eclipse,所以不能.顺便说一句,蚂蚁文档对我来说是胡言乱语.这些例子根本没有用.我已经数不清我尝试了多少.

I'm generating Android apk files with Ant. I can't use Eclipse, so no. And by the way, the ant documentation is gibberish to me. Those examples are of no use at all. I've lost count on how much I've tried.

我尝试使用 Dfile.encoding 选项,尝试将其与 CHCP 65001 Windows 命令混合使用.做了所有的组合,它甚至让 Ant(我猜是 Javac)停止吐出错误,但它仍然无关紧要.我的代码仍然以垃圾字符结尾(一堆 ?? 而不是 á、í 等).

I've tried using the Dfile.encoding option, tried mixing that with CHCP 65001 Windows command. Did all the combinations, and it even makes Ant (Javac I guess) stop spitting errors, but it still doesn't matter. My code still ends up with garbage carachters (a bunch of ?? instead of á, í etc).

推荐答案

致所有在 Windows 上使用 UTF-8 源文件并尝试使用 Dan Galpin/Tim Bray 的著名博文.

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.

javac 会出现这种编码问题(感谢提示,JesperE).但是,我无法在我的项目文件上创建新的 javac 规则,因为我对所需的参数一无所知.所以这是一个简单的答案(可能不是唯一的答案):

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. 试试常用的ant release"命令.
  2. 请注意,在开始时,有一个输出谈论一些导入的 ANT 规则.在开始时,您会看到一些 [设置] 规则.寻找这个:

  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] 导入规则文件:tools\ant\ant_rules_r3.xml

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

找到该文件并打开它.搜索javac 编码".你会看到它被设置为ascii".更改为UTF-8".

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

我就是这样做的.我确信有一种方法可以在每个项目的基础上覆盖它.但正如我所说,它一直在强制参数上给我错误.所以至少对我来说,这样做要容易得多.此外,无论如何我只使用 UTF-8.

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.

这篇关于Windows 上的 Ant 编码问题 - UTF-8 文件但在变音符号上吐出垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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