cdm/src/main/java/ucar/unidata/util/StringUtil2.java
static public String unescape(String x) {
    if (x.indexOf('%') < 0) {
      return x;
    }

    // gotta do it
    char[] b = new char[2];
    StringBuilder sb = new StringBuilder(x);
    for (int pos = 0; pos < sb.length(); pos++) {
      char c = sb.charAt(pos);
      if (c != '%') {
        continue;
      }
      if (pos >= sb.length() - 2) { // malformed - should be %xx
        return x;
      }
      b[0] = sb.charAt(pos + 1);
      b[1] = sb.charAt(pos + 2);
      int value;
      try {
        value = Integer.parseInt(new String(b), 16);
      } catch (NumberFormatException e) {
        continue;   // not a hex number
      }
      c = (char) value;
      sb.setCharAt(pos, c);
      sb.delete(pos + 1, pos + 3);
    }

    return sb.toString();
  }
static public String unescape(String x) {
    if (x.indexOf('%') < 0) {
      return x;
    }

    // gotta do it
    char[] b = new char[2];
    StringBuilder sb = new StringBuilder(x);
    for (int pos = 0; pos < sb.length(); pos++) {
      char c = sb.charAt(pos);
      if (c != '%') {
        continue;
      }
      if (pos >= sb.length() - 2) { // malformed - should be %xx
        return x;
      }
      b[0] = sb.charAt(pos + 1);
      b[1] = sb.charAt(pos + 2);
      int value;
      try {
        value = Integer.parseInt(new String(b), 16);
      } catch (NumberFormatException e) {
        continue;   // not a hex number
      }
      c = (char) value;
      sb.setCharAt(pos, c);
      sb.delete(pos + 1, pos + 3);
    }

    return sb.toString();
  }
static public String unescape ( String x ) { if ( x . indexOf ( ' ' ) < 0 ) { return x ; } // gotta do it
 char [ ] b = new char [ 2 ] ; StringBuilder sb = new StringBuilder ( x ) ; for ( int pos = 0 ; pos < sb . length ( ) ; pos ++ ) { char c = sb . charAt ( pos ) ; if ( c != ' ' ) { continue ; } if ( pos >= sb . length ( ) - 2 ) { // malformed - should be %xx
 return x ; } b [ 0 ] = sb . charAt ( pos + 1 ) ; b [ 1 ] = sb . charAt ( pos + 2 ) ; int value ; try { value = Integer . parseInt ( new String ( b ) , 16 ) ; } catch ( NumberFormatException e ) { continue ; // not a hex number
 } c = ( char ) value ; sb . setCharAt ( pos , c ) ; sb . delete ( pos + 1 , pos + 3 ) ; } return sb . toString ( ) ; }
This finds any '%xx' and converts to the equivalent char. Inverse of
escape().

@param x operate on this String
@return original String.
This finds any %xx and converts to the equivalent char . Inverse of escape () .