在java中获取char值 [英] get char value in java
问题描述
如何获取Java中的char的UTF8代码?
我有char'a',我想要值97
我有char'é',我想要值233
How can I get the UTF8 code of a char in Java ? I have the char 'a' and I want the value 97 I have the char 'é' and I want the value 233
这里是更多值的表格
我试过 Character.getNumericValue(a)
但是它给了我10而不是97,任何想法为什么?
I tried Character.getNumericValue(a)
but for a it gives me 10 and not 97, any idea why?
这看起来很基本,但任何帮助将不胜感激。
This seems very basic but any help would be appreciated!
推荐答案
/ code>实际上是一个数字类型,包含unicode值(UTF-16,确切地说 - 你需要两个
char
表示字符外的字符)。你可以做一切,你可以做一个 int
。
char
is actually a numeric type containing the unicode value (UTF-16, to be exact - you need two char
s to represent characters outside the BMP) of the character. You can do everything with it that you can do with an int
.
getNumericValue()
尝试将该字符解释为数字。
Character.getNumericValue()
tries to interpret the character as a digit.
这篇关于在java中获取char值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!