I want to convert only the special characters to their UTF-8 equivalent character.
For example given a String: Abcds23#$_ss
, it should get converted to Abcds23353695ss
.
The following is how i did the above conversion:
The utf-8 in hexadecimal for #
is 23 and in decimal is 35. The utf-8 in hexadecimal for $
is 24 and in decimal is 36. The utf-8 in hexadecimal for _
is 5f and in decimal is 95.
I know we have the String.replaceAll(String regex, String replacement)
method. But I want to replace specific character with their specific UTF-8 equivalent.
How do I do the same in java?