Java Unicode to String unicodeToString(String unicodeStr)

Here you can find the source of unicodeToString(String unicodeStr)

Description

unicode To String

License

Apache License

Declaration

public static String unicodeToString(String unicodeStr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String unicodeToString(String unicodeStr) {
        StringBuffer sb = new StringBuffer();
        String[] str = unicodeStr.toUpperCase().split("\\\\U");
        for (int i = 0; i < str.length; i++)
            if (!str[i].equals("")) {
                char c = (char) Integer.parseInt(str[i].trim(), 16);
                sb.append(c);// w  w  w . j av  a 2  s  .co m
            }
        return sb.toString();
    }

    public static String toString(Object obj, boolean autoQuote) {
        StringBuilder sb = new StringBuilder();
        if (obj == null) {
            sb.append("NULL");
        } else if ((obj instanceof Object[])) {
            for (int i = 0; i < ((Object[]) obj).length; i++) {
                sb.append(((Object[]) obj)[i]).append(", ");
            }
            if (sb.length() > 0)
                sb.delete(sb.length() - 2, sb.length());
        } else {
            sb.append(obj.toString());
        }

        if ((autoQuote) && (sb.length() > 0) && ((sb.charAt(0) != '[') || (sb.charAt(sb.length() - 1) != ']'))
                && ((sb.charAt(0) != '{') || (sb.charAt(sb.length() - 1) != '}'))) {
            sb.insert(0, "[").append("]");
        }
        return sb.toString();
    }
}

Related

  1. unicodeToAscii(String name, StringBuffer result)
  2. unicodeToAscii(String theString)
  3. unicodeToString(int unicode)
  4. unicodeToString(String escaped)
  5. unicodeToString(String hex)