Class URIEncoderDecoder


  • public class URIEncoderDecoder
    extends Object
    • Constructor Detail

      • URIEncoderDecoder

        public URIEncoderDecoder()
    • Method Detail

      • quoteIllegal

        public static String quoteIllegal​(String s,
                                          String legal)
                                   throws UnsupportedEncodingException
        All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') and legal characters are converted into their hexidecimal value prepended by '%'.

        For example: '#' -> %23

        Other characters, which are Unicode chars that are not US-ASCII, and are not ISO Control or are not ISO Space chars, are preserved.

        Called from URI.quoteComponent() (for multiple argument constructors)

        Parameters:
        s - java.lang.String the string to be converted
        legal - java.lang.String the characters allowed to be preserved in the string s
        Returns:
        java.lang.String the converted string
        Throws:
        UnsupportedEncodingException
      • decode

        public static String decode​(String s)
                             throws UnsupportedEncodingException
        Decodes the string argument which is assumed to be encoded in the x-www-form-urlencoded MIME content type using the UTF-8 encoding scheme.

        '%' and two following hex digit characters are converted to the equivalent byte value. All other characters are passed through unmodified.

        e.g. "A%20B%20C %24%25" -> "A B C $%"

        Called from URI.getXYZ() methods

        Parameters:
        s - java.lang.String The encoded string.
        Returns:
        java.lang.String The decoded version.
        Throws:
        UnsupportedEncodingException