code: private static String urlencode(
              final String content,
              final Charset charset,
              final BitSet safechars,
              final boolean blankAsPlus) {
          if (content == null) {
              return null;
          }
          StringBuilder buf = new StringBuilder();
          ByteBuffer bb = charset.encode(content);
          while (bb.hasRemaining()) {
              int b = bb.get() & 0xff;
              if (safechars.get(b)) {
                  buf.append((char) b);
              } else if (blankAsPlus && b == ' ') {
                  buf.append('+');
              } else {
                  buf.append("%");
                  char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX));
                  char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX));
                  buf.append(hex1);
                  buf.append(hex2);
              }
          }
          return buf.toString();
      }
docs: Emcode/escape a portion of a URL, to use with the query part ensure {@code plusAsBlank} is true.
  
  @param content the portion to decode
  @param charset the charset to use
  @param blankAsPlus if {@code true}, then convert space to '+' (e.g. for www-url-form-encoded content), otherwise leave as is.
  @return