code: public static String encodeUriComponent(String source, String encoding, Type type)
              throws UnsupportedEncodingException {
  
          if (source == null) {
              return null;
          }
          assertNotEmpty(encoding, "Encoding");
          byte[] bytes = encodeBytes(source.getBytes(encoding), type);
          return new String(bytes, "US-ASCII");
      }
docs: Encode the given source into an encoded String using the rules specified
  by the given component and with the given options.
  @param source the source string
  @param encoding the encoding of the source string
  @param type the URI component for the source
  @return the encoded URI
  @throws IllegalArgumentException when the given uri parameter is not a valid URI