I have the following string \u5733. I need to convert this to its respective UTF value. I tried doing it in both the ways shown below but I end up with “?” as the output. The UTF code points is for a Chinese character.Any help would be appreciated.
char[] arr=Character.toChars(5733);
System.out.println(new String(arr));
String code = "5733";
char c = (char)Integer.parseInt(code, 16);
System.out.println("Code: " + code + " Character: " + c);
You seem to have a problem with the terminal where your output is shown since your second approach is working for me.
Your first approach contains an error though. Since 5733 is a hexadecimal number, you should prefix it with
0x:An even simpler method would be: