code: public static String encodeNonCodes(String string) {
          Matcher matcher = nonCodes.matcher(string);
          StringBuffer buf = new StringBuffer();
  
          // FYI: we do not use the no-arg matcher.find()
          // coupled with matcher.appendReplacement()
          // because the matched text may contain
          // a second % and we must make sure we
          // encode it (if necessary).
          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();
      }
docs: Encode '%' if it is not an encoding sequence
  
  @param string
  @return