public static String encodeNonCodes(String string){
  Matcher matcher=nonCodes.matcher(string);
  StringBuffer buf=new StringBuffer();
  int idx=0;
  while (matcher.find(idx)) {
    int start=matcher.start();
    buf.append(string.substring(idx,start));
    buf.append("%25");
    idx=start + 1;
  }
  buf.append(string.substring(idx));
  return buf.toString();
}

public static String encodeNonCodes ( String string ) { Matcher matcher = nonCodes . matcher ( string ) ; StringBuffer buf = new StringBuffer ( ) ; int idx = 0 ; while ( matcher . find ( idx ) ) { int start = matcher . start ( ) ; buf . append ( string . substring ( idx , start ) ) ; buf . append ( "%25" ) ; idx = start + 1 ; } buf . append ( string . substring ( idx ) ) ; return buf . toString ( ) ; }
encode ' % ' if it is not an encoding sequence
