encode, decode, et al

URL functions


encode :: [Char] -> [Char]
decode :: [Char] -> [Char]
encodeQuery :: [([Char], [Char])] -> [Char]
decodeQuery :: [Char] -> [([Char], [Char])]


Spaces, and other special characters, are not allowed in URLs, so there is an escape mechanism to represent them.

The function encode converts a string by escaping special characters, returning a string suitable for use in a URL. The function decode undoes the effect of encode

When the contents of a form (here referred to as a query) is submitted to a web server, it is encoded as a sequence of pairs of field names and values in the following way:


Special characters, like =, & and spaces, occuring in the field names and values, are escaped, as with the function encode.

The functions encodeQuery and decodeQuery convert to and from the above form, applying encode and decode, respectively, to the parts of the query.


  encode "Sixth Sense, The (1999)" = "Sixth+Sense%2C+The+%281999%29"

deocdeQuery "year=1999&actor=Willis%2C+Bruce" = [("year","1999"),("actor","Willis, Bruce")]

See Also

The type URL.

The Computing dictionary entry for URL.