Unescape unicode \\ in Java String
I ran into a problem where my unicode slashes (\\) were not escaped properly. I had the following unicode string in a java variable:
\\u0011\\u00FF\\u0000\\u0001
To get correct 4 bytes out of this unicode string you must use StringEscapeUtils.unescapeJava(unicodeString) available inside Apache’s Common Lang jar.
The method will correctly edit the above unicode string into:
\u0011\u00FF\u0000\u0001
So, on calling getBytes() on your new unescaped string you will get 4 bytes.
Advertisement
leave a comment