The list of methods to do Unicode are organized into topic(s).
String
unicode(String ipStr) unicode
if (ipStr == null)
return ipStr;
switch (ipStr) {
case "\\u0001":
return "\u0001";
case "\\u0002":
return "\u0002";
case "\\u0003":
...
String
unicode(String s) unicode
final StringBuilder result = new StringBuilder();
for (char c : s.toCharArray()) {
if (c > 127 || c == '&' || c == '|') {
final int i = c;
result.append("" + i + ";");
} else {
result.append(c);
return result.toString();
void
unicode(StringBuilder buf, char c) Represent as unicode
buf.append("\\u");
int n = c;
for (int i = 0; i < 4; ++i) {
int digit = (n & 0xf000) >> 12;
buf.append(hex[digit]);
n <<= 4;
String
Unicode2ASCII(String unicode) Creates a new instance of ThaiUtil
StringBuffer ascii = new StringBuffer(unicode);
int code;
for (int i = 0; i < unicode.length(); i++) {
code = (int) unicode.charAt(i);
if ((0xE01 <= code) && (code <= 0xE5B)) {
ascii.setCharAt(i, (char) (code - 0xD60));
return ascii.toString();
byte[]
unicode2Byte(String s) unicode Byte
int len = s.length();
byte abyte[] = new byte[len << 1];
int j = 0;
for (int i = 0; i < len; i++) {
char c = s.charAt(i);
abyte[j++] = (byte) (c & 0xff);
abyte[j++] = (byte) (c >> 8);
return abyte;
String
Unicode2GBK(String dataStr) Unicode GBK
int index = 0;
StringBuffer buffer = new StringBuffer();
int li_len = dataStr.length();
while (index < li_len) {
if (index >= li_len - 1 || !"\\u".equals(dataStr.substring(index, index + 2))) {
buffer.append(dataStr.charAt(index));
index++;
continue;
...
String
unicode2native(String s) unicodenative
if (s == null || s.length() == 0) {
return "";
char ac[] = new char[s.length() * 2];
int i = 0;
for (int j = 0; j < s.length(); j++) {
if (s.charAt(j) >= '\u0100') {
char c = s.charAt(j);
...
String
unicodeCodepointToString(char cp, boolean shortenIfPossible, String prefix, boolean upperCase) Like #unicodeCodepointToString(char,boolean) if you pass in
"\\u" as prefix.
if (shortenIfPossible) {
if ((cp >= 'a' && cp <= 'z') || (cp >= 'A' && cp <= 'Z') || (cp >= '0' && cp <= '9') || cp == '\\'
|| cp == '~' || cp == '`' || cp == '.' || cp == ',' || cp == ' ' || cp == '\'' || cp == '"'
|| cp == '+' || cp == '-' || cp == '=' || cp == '_' || cp == '@' || cp == '!' || cp == '#'
|| cp == '$' || cp == '%' || cp == '^' || cp == '&' || cp == '*' || cp == ':' || cp == '['
|| cp == ']' || cp == '(' || cp == ')' || cp == '{' || cp == '}')
return new String(new char[] { cp });
if ('\t' == cp)
...
String
unicodeConvert(String str) unicode Convert
char[] in = str.toCharArray();
int off = 0;
int len = str.length();
char[] out = new char[len];
int outLen = 0;
while (off < len) {
char aChar = in[(off++)];
if (aChar == '\\') {
...