- form-urlencoded-separator #!optional char-set/char/stringparameter
- (form-urlencode alist #!key (separator (form-urlencoded-separator))) => stringprocedure
- (form-urldecode string #!key (separator (form-urlencoded-separator))) => alistprocedure
Encode or decode an alist using the encoding corresponding to the form-urlencoded media type, using the given separator character(s).
The alist contains key/value pairs corresponding to the values in the final urlencoded string. If a value is #f, the key will be omitted from the string. If it is #t the key will be present without a value. In all other cases, the value is converted to a string and urlencoded. The keys are always converted to a string and urlencoded.
When encoding, if separator is a string, the first character will be used as the separator in the resulting querystring. If it is a char-set, it will be converted to a string and its first character will be taken. In either case, all of these characters are encoded if they occur inside the key/value pairs.
When decoding, any character in the set (or string) will be seen as a separator.
The separator defaults to the string ";&". This means that either semicolons or ampersands are allowed as separators when decoding an URI string, but semicolons are used when generating strings.
If you would like to use a different separator, you should parameterize all calls to procedures that return an uri-common object.
(form-urlencode '(("lemon" . "ade") (sucks . #f) (rocks . #t) (number . 42))) => "lemon=ade;rocks;number=42" (form-urldecode "lemon=ade;rocks;number=42") => ((lemon . "ade") (rocks . #t) (number . "42"))