code: @Nonnull
      public static String rawEncode(@Nonnull String s) {
          boolean escaped = false;
          StringBuilder out = null;
          CharsetEncoder enc = null;
          CharBuffer buf = null;
          char c;
          for (int i = 0, m = s.length(); i < m; i++) {
              c = s.charAt(i);
              if (c > 122 || uriMap[c]) {
                  if (!escaped) {
                      out = new StringBuilder(i + (m - i) * 3);
                      out.append(s.substring(0, i));
                      enc = StandardCharsets.UTF_8.newEncoder();
                      buf = CharBuffer.allocate(1);
                      escaped = true;
                  }
                  // 1 char -> UTF8
                  buf.put(0,c);
                  buf.rewind();
                  try {
                      ByteBuffer bytes = enc.encode(buf);
                      while (bytes.hasRemaining()) {
                          byte b = bytes.get();
                          out.append('%');
                          out.append(toDigit((b >> 4) & 0xF));
                          out.append(toDigit(b & 0xF));
                      }
                  } catch (CharacterCodingException ex) { }
              } else if (escaped) {
                  out.append(c);
              }
          }
          return escaped ? out.toString() : s;
      }
docs: Encode a single path component for use in an HTTP URL.
  Escapes all non-ASCII, general unsafe (space and {@code "#%<>[\]^`{|}~})
  and HTTP special characters ({@code /;:?}) as specified in RFC1738.
  (so alphanumeric and {@code !@$&*()-_=+',.} are not encoded)
  Note that slash ({@code /}) is encoded, so the given string should be a
  single path component used in constructing a URL.
  Method name inspired by PHP's rawurlencode.