Assuming I have a string foo = "This is an apple"
The Unicode code point equivalent will be
" \\x74\\x68\\x69\\x73.......... \\x61\\x70\\x70\\x6c\\x65
"
T h i s ............. a p p l e
How do I convert from String foo
to
String " \\x74\\x68\\x69\\x73.......... \\x61\\x70\\x70\\x6c\\x65
"
try this..
public static String generateUnicode(String input) {
StringBuilder b = new StringBuilder(input.length());
for (char c : input.toCharArray()) {
b.append(String.format("\\u%04x", (int) c));
}
return b.toString();
}
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