Java String Unescape unescape(String str)

Here you can find the source of unescape(String str)

Description

unescape

License

Apache License

Declaration

private static String unescape(String str) 

Method Source Code

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

public class Main {
    private static String unescape(String str) {
        StringBuilder sb = new StringBuilder();
        String[] codeStrs = str.split("\\\\u");
        for (String codeStr : codeStrs) {
            if (codeStr.isEmpty()) {
                continue;
            }/*from  ww  w .j  av a 2  s  . c  om*/
            try {
                if (codeStr.length() <= 4) {
                    sb.append(Character.valueOf((char) Integer.parseInt(
                            codeStr, 16)));
                } else {
                    sb.append(Character.valueOf((char) Integer.parseInt(
                            codeStr.substring(0, 4), 16)));
                    sb.append(codeStr.substring(4));
                }
            } catch (NumberFormatException e) {
                sb.append(codeStr);
            }
        }
        return sb.toString();
    }
}

Related

  1. unescape(String str)
  2. unescape(String str)
  3. unescape(String str)
  4. unescape(String str)
  5. unescape(String str)
  6. unescape(String str)
  7. unescape(String str)
  8. unescape(String str)
  9. unescape(String str)