I need to convert unicode string to string which have non-ascii characters encoded in unicode. For example, string "漢字 Max" should be presented as "u6F22u5B57 Max".
What I have tried:
Differenct combinations of
new String(sourceString.getBytes(encoding1), encoding2)
Apache StringEscapeUtils which escapes also ascii chars like double-quote
StringEscapeUtils.escapeJava(source)
Is there an easy way to encode such string? Ideally only Java 6 SE or Apache Commons should be used to achieve desired result.
See Question&Answers more detail:os