“用于编码的不可映射字符” Java中的警告 [英] "unmappable character for encoding" warning in Java
问题描述
/ src / com /myco/apps/AppDBCore.java:439:警告:用于编码UTF8的unmappable字符
[javac] String copyright = 2003-2008 My Company。保留所有权利。
我不知道SO将如何在日期之前呈现字符,但它应该是版权符号,并在警告中作为钻石中的问号显示。
值得注意的是,该字符正确显示在输出工件中,但警告是一个麻烦并且包含此类的文件可能有一天会被保存编码不正确的文本编辑器触摸...
如何将此字符注入版权字符串所以编译器是快乐的,符号被保存在文件中,没有潜在的重新编码问题?
使用 \uxxxx转义格式。
根据维基百科,版权符号是unicode U + 00A9,所以你的行应该是:
String copyright =\\\© 2003-2008我公司所有权利先得。
I'm currently working on a Java project that is emitting the following warning when I compile:
/src/com/myco/apps/AppDBCore.java:439: warning: unmappable character for encoding UTF8
[javac] String copyright = "� 2003-2008 My Company. All rights reserved.";
I'm not sure how SO will render the character before the date, but it should be a copyright symbol, and is displayed in the warning as a question mark in a diamond.
It's worth noting that the character appears in the output artifact correctly, but the warnings are a nuisance and the file containing this class may one day be touched by a text editor that saves the encoding incorrectly...
How can I inject this character into the "copyright" string so that the compiler is happy, and the symbol is preserved in the file without potential re-encoding issues?
Use the "\uxxxx" escape format.
According to Wikipedia, the copyright symbol is unicode U+00A9 so your line should read:
String copyright = "\u00a9 2003-2008 My Company. All rights reserved.";
这篇关于“用于编码的不可映射字符” Java中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!