Decode URL-encoded string.
decode-url will decode <string> (created by encode-url
or other URL-encoding software) and store the result back into it (i.e. it will be modified). An optional "output-length"
clause lets you get the length of decoded string (which is always lesser or equal than the length of the encoded string) in <decoded length>, which can be created with optional "define"
. <length> in optional "input-length"
clause specifies the number of bytes to decode; if omitted or negative, it is the string length of <string>.
All encoded values (starting with %) are decoded, and "+"
(plus sign) is converted to space. If there is an error (for example hexadecimal value following % is invalid), the decoding stops and whatever was decoded up to that point is the result, and the length reflects that.
Note that <string> must not be a constant because decode-url will write into it. If it is a constant, make a copy of it first with copy-string
Decode URL-encoded string "str"
, after which it will hold a decoded string. "dec_len"
will be the length (in bytes) of that string:
decode-url str output-length define dec_len