Purpose
This function encodes non-ASCII characters in a string into ASCII characters. It converts non-alphanumeric characters in expr to the form of % followed by two hexadecimal digits.
Note
This function is supported starting from OceanBase Database V4.3.5 BP1.
Limitations and considerations
- This function only supports the
utf8character set. - If the input is of the string type, the output collation remains the same as the input. If the input is not of the string type, the output collation is the default collation of the current session.
Syntax
URL_ENCODE(expr)
Parameters
expr: the string to be URL-encoded.
Return type
- Returns a URL-encoded string of the
VARCHARtype. - Returns
NULLifexprisNULL.
Examples
SELECT URL_ENCODE('https://example.com/path?name=John Doe&age=25'), URL_ENCODE(NULL);
The return result is as follows:
+-----------------------------------------------------------------+------------------+
| URL_ENCODE('https://example.com/path?name=John Doe&age=25') | URL_ENCODE(NULL) |
+-----------------------------------------------------------------+------------------+
| https%3A%2F%2Fexample.com%2Fpath%3Fname%3DJohn%20Doe%26age%3D25 | NULL |
+-----------------------------------------------------------------+------------------+
1 row in set