Java String Unescape unescape(String string)

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

Description

unescape

License

Open Source License

Declaration

public static String unescape(String string) 

Method Source Code

//package com.java2s;

public class Main {
    private static final byte[] val = { 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 63, 63, 63, 63, 63, 63, 63, 10, 11, 12, 13, 14, 15, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 10, 11,
            12, 13, 14, 15, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
            63 };//w ww  .  j  av  a2  s . c om

    public static String unescape(String string) {
        StringBuffer stringbuffer = new StringBuffer();
        int i = 0;
        for (int i_2_ = string.length(); i < i_2_; i++) {
            char c = string.charAt(i);
            if ('A' <= c && c <= 'Z')
                stringbuffer.append((char) c);
            else if ('a' <= c && c <= 'z')
                stringbuffer.append((char) c);
            else if ('0' <= c && c <= '9')
                stringbuffer.append((char) c);
            else if (c == '-' || c == '_' || c == '.' || c == '!' || c == '~' || c == '*' || c == '\'' || c == '('
                    || c == ')')
                stringbuffer.append((char) c);
            else if (c == '%') {
                int i_3_ = 0;
                if ('u' != string.charAt(i + 1)) {
                    i_3_ = i_3_ << 4 | val[string.charAt(i + 1)];
                    i_3_ = i_3_ << 4 | val[string.charAt(i + 2)];
                    i += 2;
                } else {
                    i_3_ = i_3_ << 4 | val[string.charAt(i + 2)];
                    i_3_ = i_3_ << 4 | val[string.charAt(i + 3)];
                    i_3_ = i_3_ << 4 | val[string.charAt(i + 4)];
                    i_3_ = i_3_ << 4 | val[string.charAt(i + 5)];
                    i += 5;
                }
                stringbuffer.append((char) i_3_);
            } else
                stringbuffer.append((char) c);
        }
        return stringbuffer.toString();
    }
}

Related

  1. unescape(String str)
  2. unescape(String str, char escapeChar, char[] targetChars, char[] escapedChars)
  3. unescape(String string)
  4. unescape(String string)
  5. unescape(String string)
  6. unescape(String string)
  7. unescape(String string, int escape)
  8. unescape(String text)
  9. unescape(String text)