public static String decode(String s,boolean convertPlus){
  if (!convertPlus && s.indexOf('%') == -1)   return s;
  StringBuffer result=new StringBuffer(s.length());
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  for (int i=0; i < s.length(); ) {
    char c=s.charAt(i);
    if (convertPlus && c == '+')     result.append(' ');
 else     if (c == '%') {
      out.reset();
      do {
        if (i + 2 >= s.length())         throw new IllegalArgumentException(Msg.getString("K01fe",i));
        int d1=Character.digit(s.charAt(i + 1),16);
        int d2=Character.digit(s.charAt(i + 2),16);
        if (d1 == -1 || d2 == -1)         throw new IllegalArgumentException(Msg.getString("K01ff",s.substring(i,i + 3),String.valueOf(i)));
        out.write((byte)((d1 << 4) + d2));
        i+=3;
      }
 while (i < s.length() && s.charAt(i) == '%');
      result.append(out.toString());
      continue;
    }
 else     result.append(c);
    i++;
  }
  return result.toString();
}

public static String decode ( String s , boolean convertPlus ) { if ( ! convertPlus && s . indexOf ( '%' ) == - 1 ) return s ; StringBuffer result = new StringBuffer ( s . length ( ) ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; for ( int i = 0 ; i < s . length ( ) ; ) { char c = s . charAt ( i ) ; if ( convertPlus && c == '+' ) result . append ( ' ' ) ; else if ( c == '%' ) { out . reset ( ) ; do { if ( i + 2 >= s . length ( ) ) throw new IllegalArgumentException ( Msg . getString ( "K01fe" , i ) ) ; int d1 = Character . digit ( s . charAt ( i + 1 ) , 16 ) ; int d2 = Character . digit ( s . charAt ( i + 2 ) , 16 ) ; if ( d1 == - 1 || d2 == - 1 ) throw new IllegalArgumentException ( Msg . getString ( "K01ff" , s . substring ( i , i + 3 ) , String . valueOf ( i ) ) ) ; out . write ( ( byte ) ( ( d1 << 4 ) + d2 ) ) ; i += 3 ; } while ( i < s . length ( ) && s . charAt ( i ) == '%' ) ; result . append ( out . toString ( ) ) ; continue ; } else result . append ( c ) ; i ++ ; } return result . toString ( ) ; }
' % ' and two following hex digit characters are converted to the equivalent byte value . all other characters are passed through unmodified . e . g . " abc % 24 % 25 " - > " abc $ % "
