//Use a string literal to assign a value to the String
String address = "I live at 22b Baker Street!";
//The same string but using Unicode values
String unicodeAddress = "\u0049\u0020\u006C\u0069\u0076\u0065"
+ "\u0020\u0061\u0074\u0020\u0032\u0032\u0042\u0020"
+ "\u0042\u0061\u006B\u0065\u0072\u0020\u0053\u0074"
+ "\u0072\u0065\u0065\u0074\u0021";
System.out.println("Here is Sherlock's address: " + address);
System.out.println("It even works using Unicode characters: " + unicodeAddress);
# 1 楼答案
您真的应该在Java代码中使用UNICODE,例如:
示例取自here
我还发现this resource对查找unicodes很有用
它避免了与特殊字符编码相关的各种问题
# 2 楼答案
如果知道该字符的unicode字符代码,可以使用\uxxx方法将字符放入代码中的字符串中
# 3 楼答案
在windows上,有一个很好的实用程序叫做charmap。exe,列出每种字体中的所有可用字符。你可以很容易地复制&;从那里粘贴字符
当您需要更多晦涩的unicode字符时,您可以尝试在其中一个网站上找到它们并复制&;粘贴它们:
http://www.isthisthingon.org/unicode/index.php
http://www.fileformat.info/info/unicode
http://www.unicode.org/charts/
# 4 楼答案
使用Notepad++(在Windows上)或任何文本编辑器打开显示特殊字符的文件。然后,复制该字符并将其粘贴到该URL(https://unicode-table.com/en/)中。通过这种方式,您可以获得该字符的四位unicode
例如,在此伪代码中,检查字符串中是否存在特殊字符(右箭头)
# 5 楼答案
这是一个alt+numpad键的表格,你可以在Windows上输入符号
http://www.irongeek.com/alt-numpad-ascii-key-combos-and-chart.html
在您的情况下,ALT+156是英镑,ALT+157或190是¥取决于您的键盘设置