Tho*_*Vos 3 java string unicode android unicode-string
请注意,这个问题不是重复的。
我有一个这样的字符串:
// My String
String myString = "U+1F600";
// A method to convert the String to a real character
String unicodeCharacter = convertStringToUnicode(myString);
// Then this should print:
System.out.println(unicodeCharacter);
Run Code Online (Sandbox Code Playgroud)
如何将此字符串转换为 unicode 字符?然后我想在一个TextView.
您要做的是在您知道代码但作为字符串时打印 unicode ......执行此操作的正常方法是使用该方法
喜欢:
System.out.print(Character.toChars(0x1f600));
Run Code Online (Sandbox Code Playgroud)
现在在你的情况下,你有
String myString = "U+1F600";
Run Code Online (Sandbox Code Playgroud)
所以你可以截断字符串,删除第一个 2 个字符,然后使用方法Integer.parseInt(valAsString, radix)将其余部分解析为整数
String myString = "U+1F600";
System.out.print(Character.toChars(Integer.parseInt(myString.substring(2), 16)));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2289 次 |
| 最近记录: |