code: public static String contextualEncode(String s, Type t) {
          return _encode(s, t, false, true);
      }
docs: Contextually encodes the characters of string that are either non-ASCII
  characters or are ASCII characters that must be percent-encoded using the
  UTF-8 encoding. Percent-encoded characters will be recognized and not
  double encoded.
  
  @param s the string to be encoded.
  @param t the URI component type identifying the ASCII characters that
  must be percent-encoded.
  @return the encoded string.