如何将unicode代码点转换为其字符表示形式? [英] How do I convert unicode codepoints to their character representation?
问题描述
如何将代表代码点的字符串转换为适当的字符?
How do I convert strings representing code points to the appropriate character?
例如,我想要一个获得 U +的函数00E4
并返回ä
。
For example, I want to have a function which gets U+00E4
and returns ä
.
我知道在角色类中我有一个function toChars(int codePoint)
,它取一个整数,但是没有函数接受这种类型的字符串。
I know that in the character class I have a function toChars(int codePoint)
which takes an integer but there is no function which takes a string of this type.
是否有内置函数或是否必须对字符串进行一些转换以获取可以发送给函数的整数?
Is there a built in function or do I have to do some transformation on the string to get the integer which I can send to the function?
推荐答案
代码点写成十六进制数字,前缀为 U +
Code points are written as hexadecimal numbers prefixed by U+
所以,你可以这样做
int codepoint=Integer.parseInt(yourString.substring(2),16);
char[] ch=Character.toChars(codepoint);
这篇关于如何将unicode代码点转换为其字符表示形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!