List of utility methods to do Unicode Create
String | toUnicodeRepresentation(String str) to Unicode Representation if (str == null) return str; StringBuilder unicodeString = new StringBuilder(); for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); if ((ch >= 0x0020) && (ch <= 0x007e)) { unicodeString.append(ch); } else { ... |
String | toUnicodeStr(int i) to Unicode Str char c1 = Integer.toHexString((i >> 12) & 0x0000000F).charAt(0); char c2 = Integer.toHexString((i >> 8) & 0x0000000F).charAt(0); char c3 = Integer.toHexString((i >> 4) & 0x0000000F).charAt(0); char c4 = Integer.toHexString((i) & 0x0000000F).charAt(0); return "\\u" + c1 + c2 + c3 + c4; |
String | toUnicodeString(byte[] ba) Similar to the return toUnicodeString(ba, 0, ba.length);
|
String | toUnicodeString(byte[] data) to Unicode String return new String(data, "UTF-8"); |
String | toUnicodeString(char c) to Unicode String StringBuilder response = new StringBuilder(); String resp = Integer.toHexString(c); for (int i = 0; i < 4 - resp.length(); i++) { response.append(0); response.append(resp); return response.toString(); |
String | toUnicodeString(char[] chars) to Unicode String StringBuffer strBuf = new StringBuffer(); for (int i = 0; i < chars.length; i++) { strBuf.append("\\u").append(Integer.toHexString(chars[i])); return strBuf.toString(); |
String | toUnicodeString(String baseString) to Unicode String return toUnicodeString(baseString, "\\u"); |
String | toUnicodeString(String s) to Unicode String StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c >= 0 && c <= 255) { sb.append(c); } else { sb.append("\\u" + Integer.toHexString(c)); return sb.toString(); |
String | toUnicodeString(String str) to Unicode String String unicode = ""; char[] charAry = new char[str.length()]; for (int i = 0; i < charAry.length; ++i) { charAry[i] = str.charAt(i); unicode = unicode + "\\u" + Integer.toString(charAry[i], 16); return unicode; |
String | toUnicodeSymbols(String s) Translate the specified string to UNICODE presented code string. StringBuffer sb = new StringBuffer(); char a[] = s.toCharArray(); for (char c : a) if (c < 256) sb.append(c); else if (c < 4096) sb.append(String.format("\\u0%h", (int) c)); else ... |