Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant: warning: unmappable character for encoding UTF8

Tags:

java

linux

ant

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 dist and it tells me numerous times that 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.

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 instructions and 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:

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

like image 906
JOHANNES_NYÅTT Avatar asked Jan 01 '13 00:01

JOHANNES_NYÅTT


People also ask

How do I resolve an Unmappable character for encoding utf8?

In eclipse try to go to file properties ( Alt + Enter ) and change the Resource → ' Text File encoding ' → Other to UTF-8 . Reopen the file and check there will be junk character somewhere in the string/file. Remove it. Save the file.

How do I fix the Unmappable character for encoding cp1252?

Go to common tab of RUN/DEBUG configuration in eclipse change encoding to UTF-8. Show activity on this post. Window > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types. Window > Preferences > General > Workspace, set "Text file encoding" to "Other : UTF-8".


2 Answers

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

For Ant:

add -Dfile.encoding=UTF8 to your ANT_OPTS environment variable

Setting the Default Java File Encoding to UTF-8:

export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

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

like image 119
Chandana Avatar answered Sep 18 '22 05:09

Chandana


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.

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

like image 40
Zagrev Avatar answered Sep 21 '22 05:09

Zagrev