Converts an input string that is in the application/x-www-form-urlencoded MIME
format into a standard string.
Syntax
string url_decode(string <input>[, string <encoding>])
Description
Converts an input string in the application/x-www-form-urlencoded MIME
format into a standard string. This is the inverse function of URL_ENCODE
. The encoding format must comply with the following rules:
All letters remain unchanged.
Periods (.), hyphens (-), asterisks (*), and underscores (_) remain unchanged.
Plus signs (+) are converted into spaces.
The
%xy
-formatted sequence is converted into byte values. Consecutive byte values are decoded to the related strings based on the value of encoding.Other characters remain unchanged.
Parameters
input: required. A value of the STRING type. This parameter specifies the string that you want to enter.
encoding: optional. This parameter specifies the encoding format, which can be GBK or UTF-8. If you do not specify this parameter, the default value UTF-8 is used.
Return value
A UTF-8 encoded string of the STRING type is returned. If the value of input or encoding is null, null is returned.
Examples
-- The return value is for url_decode:// (fdsf).
select url_decode('%E7%A4%BA%E4%BE%8Bfor+url_decode%3A%2F%2F+%28fdsf%29');
-- The return value is Example for URL_DECODE:// dsf(fasfs).
select url_decode('Example+for+url_decode+%3A%2F%2F+dsf%28fasfs%29', 'GBK');
Related functions
URL_DECODE is a string function. For more information about functions related to string searches and conversion, see String functions.