Java Utililty Methods Unicode to String

List of utility methods to do Unicode to String

Description

The list of methods to do Unicode to String are organized into topic(s).

Method

StringUnicode2Str(String s)
Unicode Str
int i = 0;
int len = s.length();
StringBuffer sb = new StringBuffer(len);
while (i < len) {
    String t = s.substring(i, i + 4);
    char c = (char) Integer.parseInt(t, 16);
    i += 4;
    sb.append(c);
...
Stringunicode2String(String unicodeStr)
unicode String
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);
return sb.toString();
...
StringunicodeStringToPrettyString(String s)
Returns the most succinct possible, human-readable, ASCII form of the String s of Unicode codepoints.
if (s == null)
    return "null";
StringBuffer sb = new StringBuffer(s.length() * 6);
for (int i = 0; i < s.length(); i++) {
    sb.append(unicodeCodepointToString(s.charAt(i), true));
return sb.toString();
voidunicodeToAscii(String name, StringBuffer result)
unicode To Ascii
for (int i = 0; i < name.length(); i++) {
    if (Character.isLetterOrDigit(name.codePointAt(i)) || Character.isSpaceChar(name.codePointAt(i))
            || name.charAt(i) == '_' || name.charAt(i) == '$') {
        result.append(name.charAt(i));
    } else {
        result.append("U+" + Integer.toHexString(name.codePointAt(i)).toUpperCase());
StringunicodeToAscii(String theString)
unicode To Ascii
char aChar;
int len = theString.length();
StringBuffer outBuffer = new StringBuffer(len * 2);
for (int x = 0; x < len;) {
    aChar = theString.charAt(x++);
    switch (aChar) {
    case '\\':
        outBuffer.append('\\');
...
StringunicodeToString(int unicode)
unicode To String
switch (unicode) {
case 0x00:
    return "\\0";
case 0x08:
    return "\\b";
case 0x09:
    return "\\t";
case 0x10:
...
StringunicodeToString(String escaped)
unicode To String
int len = escaped.length();
StringBuffer buf = new StringBuffer();
int value = 0;
for (int x = 0; x < len;) {
    int c = escaped.charAt(x++);
    if (c == 92) {
        c = escaped.charAt(x++);
        if (c == 117) {
...
StringunicodeToString(String hex)
unicode To String
int t = hex.length() / 6;
int iTmp = 0;
StringBuilder str = new StringBuilder();
for (int i = 0; i < t; i++) {
    String s = hex.substring(i * 6, (i + 1) * 6);
    iTmp = Integer.valueOf(s.substring(2, 4), 16).intValue() << 8
            | Integer.valueOf(s.substring(4), 16).intValue();
    str.append(new String(Character.toChars(iTmp)));
...
StringunicodeToString(String unicodeStr)
unicode To String
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);
return sb.toString();
...