[英]Java Convert special characters into Unicode
I am using a Special Character in Java, which is causing an issue when I compile with UTF-8 encoding. 我在Java中使用特殊字符,因此在使用UTF-8编码进行编译时会引起问题。 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. 这是另一件事:我还必须弄清楚如何将其转换为Unicode。
If you know the unicode number of the character you can escape it as follows: 如果您知道字符的unicode号,可以按以下步骤对其进行转义:
language = new SelectOption<String>("default", "Default/d\u2202faut");
where 2202 is the unicode number 其中2202是unicode号
If the source file in UTF-8 compile it as javac -encoding UTF-8 ...
and there will be no problem. 如果UTF-8中的源文件将其编译为javac -encoding UTF-8 ...
,就不会有问题。
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 要将源文件转换为Unicode编码,请使用来自JDK http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/native2ascii.html的 native2ascii
util
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.