I am making an ASCII Encoder-Decoder. I am encoding the characters into UTF-8. To encode I am using this code:
private String asciiReturn(String inpString){
int codePoint = 0;
StringBuilder str = new StringBuilder();
for (int i = 0; i < inpString.length(); i++){
codePoint = Character.codePointAt(inpString, i);
i += Character.charCount(codePoint) - 1;
str.append(codePoint);
str.append(" ");
}
return str.toString();
}
So by this, I can encode all those emoji characters too.
Like '♂️' for this emoji I am getting "129335 127995 8205 9794 65039". So this is basically the UTF-8 decimal value of the emoji and that's exactly what I want. But my problem is the decoding.
What I want is: (Example)
Input String: "72 117 104 33 129335 127995 8205 9794 65039"
Output String: "Huh!♂️"
Cause:
72 -> 'H'
117 -> 'u'
104 -> 'h'
33 -> '!'
129335 127995 8205 9794 65039 -> '♂️'
Thanks in advance