List of utility methods to do Unicode Escape
String | unicodeEscapeEncode(String unicode) Performs escape encoding on the given string so that it can be represented using 1-byte characters. StringBuilder result = new StringBuilder(unicode.length()); for (int i = 0, size = unicode.length(); i < size; ++i) { char character = unicode.charAt(i); if (character > '\u00ff') { result.append("\\u"); String hex = Integer.toString(character, 16); for (int j = hex.length(); j < 4; ++j) { result.append("0"); ... |
String | unicodeHexEscapeJava(char ch) converts a char to a java-style unicode escaped string if (ch < 0x10) { return "\\u000" + Integer.toHexString(ch); } else if (ch < 0x100) { return "\\u00" + Integer.toHexString(ch); } else if (ch < 0x1000) { return "\\u0" + Integer.toHexString(ch); return "\\u" + Integer.toHexString(ch); ... |
String | unicodeUnescape(String st) unicode Unescape StringBuilder sb = new StringBuilder(st.length()); for (int i = 0; i < st.length(); i++) { char ch = st.charAt(i); if (ch == '\\') { char nextChar = (i == st.length() - 1) ? '\\' : st.charAt(i + 1); if (nextChar >= '0' && nextChar <= '7') { String code = "" + nextChar; i++; ... |