The UTL_ENCODE
package provides functions that encode RAW
data into a standard encoded format so that the data can be transported between hosts. You can use UTL_ENCODE
functions to encode the body of email text. The package also contains the decode counterpart functions of the encode functions. The functions follow published standards for encoding to accommodate non-Oracle utilities on the sending or receiving ends.
This chapter contains the following topic:
Table 223-1 UTL_ENCODE Package Subprograms
Subprogram | Description |
---|---|
Reads the base 64-encoded |
|
Encodes the binary representation of the |
|
Decodes a string from mime header format |
|
Encodes a string into mime header format |
|
Reads the |
|
Reads the |
|
Decodes a character set sensitive text string |
|
Encodes a character set sensitive text string |
|
Reads the |
|
Reads the |
This function reads the base 64-encoded RAW
input string and decodes it to its original RAW
value.
This function encodes the binary representation of the RAW
value into base 64 elements and returns it in the form of a RAW
string.
This function accepts as input an "encoded word" of the form:
=?<charset>?<encoding>?<encoded text>?= =?ISO-8859-1?Q?Here is some encoded text?=
The <encoded text>
is encapsulated in mime header tags which give the MIMEHEADER_DECODE
function information about how to decode the string. The mime header metadata tags are stripped from the input string and the <encoded text>
is converted to the base database character set as follows:
If this is a UTF16 platform, convert the encoded text from UTF16 to ASCII
If this is an EBCDIC platform, convert the encoded text from EBCDIC to ASCII
If this is an ASCII or UTF8 platform, no conversion needed
The string is decoded using either quoted-printable or base64 decoding, as specified by the <encoding>
metadata tag in the encoded word. The resulting converted and decoded text is returned to the caller as a VARCHAR2
string.
UTL_ENCODE.MIMEHEADER_DECODE ( buf IN VARCHAR2 CHARACTER SET ANY_CS) RETURN data VARCHAR2 CHARACTER SET buf%CHARSET;
This function returns as an output an "encoded word" of the form:
=?<charset>?<encoding>?<encoded text>?= =?ISO-8859-1?Q?Here is some text?=
The buf
input parameter is the text to be encoded and becomes the <encoded text>
.
The <encoding> value is either "Q" or "B" for quoted-printable encode or base64 encoding respectively. The ENCODING input parameter accepts as valid values UTL_ENCODE.QUOTED_PRINTABLE
or UTL_ENCODE.BASE64
or NULL
. If NULL
, quoted-printable encoding is selected as a default value.
The <charset>
value is specified as the input parameter encode_charset
. If NULL
, the database character set is selected as a default value.
The mimeheader encoding process includes conversion of the buf
input string to the character set specified by the encode_charset
parameter. The converted string is encoded to either quoted-printable or base64 encoded format. The mime header tags are appended and prepended.
Finally, the string is converted to the base character set of the database:
If this is a UTF16 platform, convert the encoded text to UTF16
If this is an EBCDIC platform, convert the encoded text to EBCDIC
If this is an ASCII or UTF8 platform, no conversion needed.
UTL_ENCODE.MIMEHEADER_ENCODE ( buf IN VARCHAR2 CHARACTER SET ANY_CS, encode_charset IN VARCHAR2 DEFAULT NULL, encoding IN PLS_INTEGER DEFAULT NULL) RETURN string VARCHAR2 CHARACTER SET buf%CHARSET;
This function reads the varchar2
quoted printable format input string and decodes it to the corresponding RAW
string.
This function reads the RAW
input string and encodes it to the corresponding quoted printable format string.
This function converts the input text to the target character set as specified by the encode_charset
parameter, if not NULL
. The encoded text is converted to the base character set of database, as follows:
If this is a UTF16 platform, convert the encoded text from UTF16 to ASCII
If this is an EBCDIC platform, convert the encoded text from EBCDIC to ASCII
If this is an ASCII or UTF8 platform, no conversion needed
You can decode from either quoted-printable or base64 format, with regard to each encoding
parameter. If NULL
, quoted-printable is selected as a default decoding format. If encode_charset
is not NULL
, you convert the string from the specified character set to the database character set. The resulting decoded and converted text string is returned to the caller.
UTL_ENCODE.TEXT_DECODE( buf IN VARCHAR2 CHARACTER SET ANY_CS, encode_charset IN VARCHAR2 DEFAULT NULL, encoding IN PLS_INTEGER DEFAULT NULL) RETURN string VARCHAR2 CHARACTER SET buf%CHARSET;
This function converts the input text to the target character set as specified by the encode_charset
parameter, if not NULL
. The text is encoded to either base64 or quoted-printable format, as specified by the encoding
parameter. Quoted-printable is selected as a default if ENCODING is NULL.
The encoded text is converted to the base character set of the database:
If this is a UTF16 platform, convert the encoded text to UTF16
If this is an EBCDIC platform, convert the encoded text to EBCDIC
If this is an ASCII or UTF8 platform, no conversion needed
The resulting encoded and converted text string is returned to the caller.
UTL_ENCODE.TEXT_ENCODE ( buf IN VARCHAR2 CHARACTER SET ANY_CS, encode_charset IN VARCHAR2 DEFAULT NULL, encoding IN PLS_INTEGER DEFAULT NULL) RETURN string VARCHAR2 CHARACTER SET buf%CHARSET;
This function reads the RAW
uuencode format input string and decodes it to the corresponding RAW
string. See "UUENCODE Function" for discussion of the cumulative nature of UUENCODE
and UUDECODE
for data streams.
This function reads the RAW
input string and encodes it to the corresponding uuencode format string. The output of this function is cumulative, in that it can be used to encode large data streams, by splitting the data stream into acceptably sized RAW
values, encoded, and concatenated into a single encoded string.
UTL_ENCODE.UUENCODE ( r IN RAW, type IN PLS_INTEGER DEFAULT 1, filename IN VARCHAR2 DEFAULT NULL, permission IN VARCHAR2 DEFAULT NULL) RETURN RAW;
Table 223-20 UUENCODE Function Parameters
Parameter | Description |
---|---|
|
|
|
Optional number parameter containing the type of uuencoded output. Options: complete—a defined PL/SQL constant with a value of |
|
Optional |
|
Optional |