I have a String representing the hex value of a char, such as: "0x6d4b". How can I get the character it represents as a char?
String c = "0x6d4b";
char m = ???
// Drop "0x" in order to parse
String c = "6d4b";
// Parse hexadecimal integer
int i = Integer.parseInt( c, 16 );
// Note that this method returns char[]
char[] cs = Character.toChars( i );
// Prints 测
System.out.println( cs );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With