httpservices/src/main/java/ucar/httpservices/Escape.java
private static String xunescapeString(String in, char escape, boolean spaceplus)
    {
        try {
            if(in == null) return null;

            byte[] utf8 = in.getBytes(utf8Charset);
            byte escape8 = (byte) escape;
            byte[] out = new byte[utf8.length]; // Should be max we need

            int index8 = 0;
            for(int i = 0; i < utf8.length; ) {
                byte b = utf8[i++];
                if(b == plus && spaceplus) {
                    out[index8++] = blank;
                } else if(b == escape8) {
                    // check to see if there are enough characters left
                    if(i + 2 <= utf8.length) {
                        b = (byte) (fromHex(utf8[i]) << 4 | fromHex(utf8[i + 1]));
                        i += 2;
                    }
                }
                out[index8++] = b;
            }
            return new String(out, 0, index8, utf8Charset);
        } catch (Exception e) {
            return in;
        }

    }
private static String xunescapeString(String in, char escape, boolean spaceplus)
    {
        try {
            if(in == null) return null;

            byte[] utf8 = in.getBytes(utf8Charset);
            byte escape8 = (byte) escape;
            byte[] out = new byte[utf8.length]; // Should be max we need

            int index8 = 0;
            for(int i = 0; i < utf8.length; ) {
                byte b = utf8[i++];
                if(b == plus && spaceplus) {
                    out[index8++] = blank;
                } else if(b == escape8) {
                    // check to see if there are enough characters left
                    if(i + 2 <= utf8.length) {
                        b = (byte) (fromHex(utf8[i]) << 4 | fromHex(utf8[i + 1]));
                        i += 2;
                    }
                }
                out[index8++] = b;
            }
            return new String(out, 0, index8, utf8Charset);
        } catch (Exception e) {
            return in;
        }

    }
private static String xunescapeString ( String in , char escape , boolean spaceplus ) { try { if ( in == null ) return null ; byte [ ] utf8 = in . getBytes ( utf8Charset ) ; byte escape8 = ( byte ) escape ; byte [ ] out = new byte [ utf8 . length ] ; // Should be max we need int index8 = 0 ; for ( int i = 0 ; i < utf8 . length ; ) { byte b = utf8 [ i ++ ] ; if ( b == plus && spaceplus ) { out [ index8 ++ ] = blank ; } else if ( b == escape8 ) { // check to see if there are enough characters left if ( i + 2 <= utf8 . length ) { b = ( byte ) ( fromHex ( utf8 [ i ] ) << 4 | fromHex ( utf8 [ i + 1 ] ) ) ; i += 2 ; } } out [ index8 ++ ] = b ; } return new String ( out , 0 , index8 , utf8Charset ) ; } catch ( Exception e ) { return in ; } }
Given a string that contains WWW escape sequences, translate those escape
sequences back into ASCII characters. Return the modified string.

@param in        The string to modify.
@param escape    The character used to signal the begining of an escape sequence.
param except If there is some escape code that should not be removed by
this call (e.g., you might not want to remove spaces, %20) use this
parameter to specify that code. The function will then transform all
escapes except that one.
@param spaceplus True if spaces should be replaced by '+'.
@return The modified string.
Given a string that contains WWW escape sequences translate those escape sequences back into ASCII characters . Return the modified string .