Reputation:
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.
Upvotes: 0
Views: 3112
Reputation: 136112
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
Upvotes: 0
Reputation:
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.
Upvotes: 0
Reputation: 7381
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
Upvotes: 3