DoublePudge
DoublePudge

Reputation: 95

Java unmappable character for encoding UTF-8 netbeans {"copy", "169"}, // ? - copyright sign

I've downloaded the apache lang source, but my netbeans encoding is UTF-8, I gen an error that:

\src\org\apache\commons\lang\Entities.java:64: error: unmappable character for encoding UTF-8
        {"copy", "169"}, // ? - copyright sign

how can I solve this?

I've tried to encode the file itself to utf-8 by notepad++ but it didn't helped

Upvotes: 0

Views: 2995

Answers (2)

kimathie
kimathie

Reputation: 426

There are 2 solutions for netbeans IDE

1.Right click on the apache lang source project and select

->Properties
  ->Sources
    ->Bottom left click the encoding drop down list and select ISO 8859-1

2. Delete the following classes

 org.apache.commons.lang.Entity
 org.apache.commons.lang.StringEscapeUtils  

Remember if you decide to go with the first solution then this will change the encoding of your project. if you want to maintain your project encoding as the default UTF-8 then use the second solution but this means you lose out on StringEscapeUtil functionality.

Upvotes: 0

Jean-François Savard
Jean-François Savard

Reputation: 21004

Try with the unicode symbol : "\u00a9".

You should not use special char directly in code, use code dedicated for this instead to avoid this kind of problems.

Edit : Using the class you mentionned in comment, you can use

StringEscapeUtils.escapeHtml(yourCharacter);

That will return your character (in your case copyright) as html code (&copy). If you want to do the reverse treatment, you can use

StringEscapeUtils.unescapeHtml(yourCode);

That will return for example the copyright sign if you pass &copy as parameter.

Upvotes: 1

Related Questions