CODE
Oracle Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
PSOUG Home Code Snippets Oracle Reference Oracle Functions PSOUG Forum Oracle Blogs Bookmark and Share
 
 Search the Reference Library pages:  

Free
Oracle Magazine
Subscriptions
and Oracle White Papers

Oracle UTL_ENCODE
Version 11.1
 
General Information
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
dms_aw_exp dbms_iot utl_enc_lib utl_mail
 
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(1000);
BEGIN
  t := utl_encode.mimeheader_encode('PSOUG');
  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
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us [108 users online]    © 2010 psoug.org