Linux 蚂蚁:警告:编码 UTF8 的不可映射字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14106936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:09:37  来源:igfitidea点击:

ant: warning: unmappable character for encoding UTF8

javalinuxant

提问by JOHANNES_NY?TT

I have seen numerous of questions like mine but they don't answer my question because I'm using ant and I'm not using eclipse. I run this code: ant clean distand it tells me numerous times that warning: unmappable character for encoding UTF8.

我见过很多像我这样的问题,但他们没有回答我的问题,因为我使用的是 ant 而我没有使用 eclipse。我运行此代码:ant clean dist它多次告诉我warning: unmappable character for encoding UTF8.

I see on the Java command that there is a -encoding option, but that doesn't help me cuz I'm using the ant.

我在 Java 命令上看到有一个 -encoding 选项,但这对我没有帮助,因为我正在使用 ant。

I'm on Linux and I'm trying to run the developer version of Sentrick; I haven't made no modifications to anything, I just downloaded it and followed all their instructionsand it ain't makes no difference. I emailed the developper and they told me it was this problem but I suspect that it is actually something that gotta do with this error at the end:

我在 Linux 上,我正在尝试运行Sentrick的开发者版本;我没有对任何内容进行任何修改,我只是下载了它并遵循了他们的所有说明,这没什么区别。我给开发人员发了电子邮件,他们告诉我这是这个问题,但我怀疑这实际上与最后这个错误有关:

BUILD FAILED
/home/daniel/sentricksrc/sentrick/build.xml:22: The following error occurred while executing this line:
/home/daniel/sentricksrc/sentrick/ant/common-targets.xml:83: Test de.denkselbst.sentrick.tokeniser.components.DetectedAbbreviationAnnotatorTest failed

I'm not sure what I'm gonna do now because I really need for it to work

我不确定我现在要做什么,因为我真的需要它来工作

采纳答案by Chandana

Try to change file encoding of your source files and set the Default Java File Encoding to UTF-8 also.

尝试更改源文件的文件编码并将默认 Java 文件编码也设置为 UTF-8。

For Ant:

对于蚂蚁:

add -Dfile.encoding=UTF8to your ANT_OPTSenvironment variable

添加-Dfile.encoding=UTF8到您的ANT_OPTS环境变量

Setting the Default Java File Encoding to UTF-8:

将默认 Java 文件编码设置为 UTF-8:

export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

Or you can start up java with an argument -Dfile.encoding=UTF8

或者你可以用一个参数启动java -Dfile.encoding=UTF8

回答by Zagrev

The problem is not eclipse or ant. The problem is that you have a build file with special characters in it. Like smart quotes or m-dashes from MS Word. Anyway, you have characters in your XML file that are not part of the UTF-8 character set. So you should fix your XML to remove those invalid characters and replace them with similar looking but valid UTF-8 versions. Look for special characters like &#64 © — ® etc. and replace them with the (c) or whatever is useful to you.

问题不在于日食或蚂蚁。问题是您有一个包含特殊字符的构建文件。就像 MS Word 中的智能引号或短划线一样。无论如何,您的 XML 文件中有不属于 UTF-8 字符集的字符。因此,您应该修复您的 XML 以删除那些无效字符,并将它们替换为外观相似但有效的 UTF-8 版本。查找特殊字符,如 @ © — ® 等,并将它们替换为 (c) 或任何对您有用的字符。

BTW, the bad character is in common-targets.xml at line 83

顺便说一句,坏字符在第 83 行的 common-targets.xml 中

回答by user5570799

Changing encoding to Cp 1252 worked for my project with same error. I tried changing eclipse properties several times but it did not help me in any way. I added encoding property to my pom.xml file and the error gone. http://ctrlaltsolve.blogspot.in/2015/11/encoding-properties-in-maven.html

将编码更改为 Cp 1252 对我的项目有效,但出现相同错误。我尝试多次更改 eclipse 属性,但它对我没有任何帮助。我在 pom.xml 文件中添加了 encoding 属性,错误消失了。http://ctrlaltsolve.blogspot.in/2015/11/encoding-properties-in-maven.html