Table of Contents
This chapter briefly introduces the UTL_URL package, and describes how to use the functions of the package.
UTL_URL provides functions to encode a URL address to an escaped format. ESCAPE is used to convert illegal characters to %xx, the hexadecimal character representation in ASCII. Reserved characters can also be escaped to allow them to be treated as literals.
Character Type | Regular Expression |
---|---|
Unreserved characters | [0-9] | [a-zA-Z] | - | _ | . | ! | ~ |* | ` | ( | ) |
Reserved characters | ; | / | ? | ; | @ | & | = | + | $ | , |
This section describes the functions provided by the UTL_URL package, in alphabetical order.
Converts a URL address to an escaped format.
Details about the ESCAPE function are as follows:
Prototype
FUNCTION ESCAPE ( url IN VARCHAR2, escape_reserved_chars IN BOOLEAN DEFAULT FALSE, url_charset IN VARCHAR2 DEFAULT utl_http.get_body_charset ) RETURN VARCHAR2;
Parameter
Parameter | Description |
---|---|
url | URL to escape. |
escape_reserved_chars | Option to convert reserved characters to an escaped format.
|
url_charset | Character set of the URL address. The default character set of the UTL_HTTP package is used by default. The default character set of the HTTP message body is 'ISO-8859-1'. |
Example
BEGIN dbms_output.put_line( UTL_URL.ESCAPE('http://www.w3.org/blah blah.html') ); END; /
Converts a URL address containing escaped (%xx) characters to a standard string.
Details about the UNESCAPE function are as follows:
Prototype
FUNCTION UNESCAPE ( url IN VARCHAR2, url_charset IN VARCHAR2 DEFAULT utl_http.get_body_charset ) RETURN VARCHAR2;
Parameter
Parameter | Description |
---|---|
url | URL to unescape. |
url_charset | Character set of the URL. The default character set of the UTL_HTTP package is used by default. The default character set of the HTTP message body is 'ISO-8859-1'. |
Exception
Exception | Description |
---|---|
URL_BAD_URL | Occurs if an invalid escaped string is encountered. |
Example
DECLARE ourl VARCHAR2(32767); eurl VARCHAR2(32767); BEGIN eurl := UTL_URL.ESCAPE('http://www.w3.org/Protocols/'); ourl := UTL_URL.UNESCAPE(eurl); END; /