java - Convert String to its Unicode code point -
assuming have string foo = "this apple"
the unicode code point equivalent be
" \\x74\\x68\\x69\\x73.......... \\x61\\x70\\x70\\x6c\\x65
"
t h s ............. p p l e
how convert 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()); (char c : input.tochararray()) { b.append(string.format("\\u%04x", (int) c)); } return b.tostring(); }
Comments
Post a Comment