Oracle UTL_ENCODE
Version 11.2.0.3
 
General Information
Purpose Encode RAW data strings
Source {ORACLE_HOME}/rdbms/admin/utlenc.sql
First Availability 9.0.1
Constants
Constant Data Type Value
base64 PLS_INTEGER 1
complete (header & footer) PLS_INTEGER 1
end_piece (includes footer text) PLS_INTEGER 4
header_piece (includes heaer text) PLS_INTEGER 2
middle_piece (body text only) PLS_INTEGER 3
quoted_printable PLS_INTEGER 2
Dependencies
DBMS_AW_EXP UTL_ENC_LIB WWV_FLOW_MAIL WWV_FLOW_UTILITIES
Security Model Execute is granted to PUBLIC with a PUBLIC synonym
Subprograms
 
BASE64_DECODE
Reads the base 64-encoded RAW input string and decodes it to its original RAW value utl_encode.base64_decode(r IN RAW) RETURN RAW;
See base64_encode demo
 
BASE64_ENCODE
Encodes the binary representation of the RAW value into base 64 elements and returns it in the form of a RAW string utl_encode.base64_encode(r IN RAW) RETURN RAW;
set serveroutput on

DECLARE
 r RAW(32767);
BEGIN
  r := utl_raw.cast_to_raw('University of Washington');
  dbms_output.put_line(r);

  r := utl_encode.base64_encode(r);
  dbms_output.put_line(r);

  r := utl_encode.base64_decode(r);
  dbms_output.put_line(r);
END;
/
 
MIMEHEADER_DECODE
Decodes a string from mime header format utl_encode.mimeheader_decode(buf IN VARCHAR2 CHARACTER SET ANY_CS)
RETURN data VARCHAR2 CHARACTER SET buf%CHARSET;
See mimeheader_encode demo
 
MIMEHEADER_ENCODE
Encodes a string into mime header format 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;
set serveroutput on

DECLARE
 t VARCHAR2(100);
BEGIN
  t := utl_encode.mimeheader_encode('MLIB');
  dbms_output.put_line(t);

  t := utl_encode.mimeheader_decode(t);
  dbms_output.put_line(t);
END;
/
 
QUOTED_PRINTABLE_DECODE
Reads the varchar2 quoted printable format input string and decodes it to the corresponding RAW string utl_encode.quoted_printable_decode(r IN RAW) RETURN RAW;
See quoted_printable_encode demo
 
QUOTED_PRINTABLE_ENCODE
Reads the RAW input string and encodes it to the corresponding quoted printable format string utl_encode.quoted_printable_encode(r IN RAW) RETURN RAW;
set serveroutput on

DECLARE
r RAW(32767);
BEGIN
  r := utl_raw.cast_to_raw('Begin' || chr(13) || 'End');
  dbms_output.put_line(r);

  r := utl_encode.quoted_printable_encode(r);
  dbms_output.put_line(r);

  r := utl_encode.quoted_printable_decode(r);
  dbms_output.put_line(r);
END;
/
 
TEXT_DECODE
Decodes a character set sensitive text string 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;
See text_encode demo
 
TEXT_ENCODE
Encodes a character set sensitive text string 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;
set serveroutput on

DECLARE
 c VARCHAR2(100);
BEGIN
  c := utl_encode.text_encode('Here is some text', 'WE8ISO8859P1', UTL_ENCODE.BASE64);

  dbms_output.put_line(c);
END;
/

DECLARE
 c VARCHAR2(100);
BEGIN
  c := utl_encode.text_decode('SGVyZSBpcyBzb21lIHRleHQ=',
  'WE8ISO8859P1', UTL_ENCODE.BASE64);

  dbms_output.put_line(c);
END;
/
 
UUDECODE
Reads the RAW uuencode format input string and decodes it to the corresponding RAW string utl_encode.uudecode(r IN RAW) RETURN RAW;
See uuencode demo
 
UUENCODE
Reads the RAW input string and encodes it to the corresponding uuencode format 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;
set serveroutput on

DECLARE
 r RAW(32767);
BEGIN
  r := utl_encode.uuencode('ABCFED', 1, 'uuencode.txt', 0);
  dbms_output.put_line('Encoded: ' || r);

  r := utl_encode.uudecode(r);
  dbms_output.put_line('Decoded: ' || r);
END;
/
 
Related Topics
UTL_MAIL
UTL_RAW
UTL_SMTP
 
Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2013 Daniel A. Morgan All Rights Reserved