I'm trying to get the java escape code.
Example: 1F612
==> \ud83d\ude12
I tried:
String toConvert = "\ud83d\ude12";
String result = "";
for(int x=0;x<toConvert.length();x++){
int codePoint = Character.codePointAt(toConvert, x);
String hexStr = Integer.toHexString(codePoint);
hexStr = formatUTF(hexStr);
result += hexStr;
}
System.out.println(result);
formatUTF function:
public static String formatUTF(String hex){
String text = hex;
for(int x = 0; x<4-hex.length();x++)
text = "0"+text;
return "\\u"+text;
}
but the output:
run:
\u1f612\ude12
Note: 1F612
Hex = 128530
Integer
please help.
Maybe this clarifies all.
It yields one single code point of two 16 bit chars.
Exactly as the UTF-16 standard says.