将字符串从application/x-www-form-urlencoded MIME
格式转为常规字符。
命令格式
string url_decode(string <input>[, string <encoding>])
命令说明
将输入字符串从
application/x-www-form-urlencoded MIME
格式转为常规字符串,是url_encode
的逆过程。编码规则如下:
- a~z、A~Z保持不变。
- 英文句点(.)、短划线(-)、星号(*)和下划线(_)保持不变。
- 加号(+)转为空格。
%xy
格式的序列转为对应的字节值,连续的字节值根据输入的encoding名称解码为对应的字符串。- 其余的字符保持不变。
参数说明
- input:必填。STRING类型。要输入的字符串。
- encoding:可选。指定编码格式,支持GBK或UTF-8等标准编码格式,不输入默认为UTF-8。
返回值说明
返回STRING类型UTF-8编码的字符串。input或encoding值为NULL时,返回NULL。
使用示例
--返回示例for url_decode:// (fdsf)。
select url_decode('%E7%A4%BA%E4%BE%8Bfor+url_decode%3A%2F%2F+%28fdsf%29');
--返回Example for URL_DECODE:// dsf(fasfs)。
select url_decode('Example+for+url_decode+%3A%2F%2F+dsf%28fasfs%29', 'GBK');