0

I am using a Special Character in Java, which is causing an issue when I compile with UTF-8 encoding. How can I deal with this problem? Here is a code snapshot.

language = new SelectOption<String>("default", "Default/d�faut");

Here's one more thing: I also have to figure out how to convert it into Unicode.

James Dunn
  • 8,064
  • 13
  • 53
  • 87

3 Answers3

3

If you know the unicode number of the character you can escape it as follows:

language = new SelectOption<String>("default", "Default/d\u2202faut");

where 2202 is the unicode number

Ernesto Campohermoso
  • 7,213
  • 1
  • 40
  • 51
0

Thanks to @Ernesto Campohermoso and @pratZ it works and here i found a link to convert Special Character to unicode .

Like Unicode of this � is \uFFFD which we can use in Java Class.

0

If the source file in UTF-8 compile it as javac -encoding UTF-8 ... and there will be no problem.

To convert the source file to Unicode-encoded use native2ascii util from JDK http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/native2ascii.html

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275