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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -