get char value in java

后端 未结 8 1618
孤街浪徒
孤街浪徒 2020-12-18 20:04

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

here is a table for more

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-18 20:52

    char is actually a numeric type containing the unicode value (UTF-16, to be exact - you need two chars to represent characters outside the BMP) of the character. You can do everything with it that you can do with an int.

    Character.getNumericValue() tries to interpret the character as a digit.

提交回复
热议问题