Search notes:

UTL_RAW.CONVERT

utl_raw.convert interprets a raw as a string encoded in a given character set and converts this string to a raw encoded in a different character set.
Compare with utl_i18n.string_to_raw.
declare
   latin_1_string_raw raw(100);
   utf_8___string_raw raw(100);
begin

  latin_1_string_raw := hextoraw(
    'e4' || -- 'ä'
    'f6' || -- 'ö'
    'fc'    -- 'ü'
  );
  
  
  utf_8___string_raw := utl_raw.convert(
    latin_1_string_raw,
    to_charset   => 'UTF8',
    from_charset => 'WE8ISO8859P1'
  );
  
  dbms_output.put_line('äöü in UTF8 is:');
  dbms_output.put_line(rawtohex(utf_8___string_raw));

end;
/
--
-- äöü in UTF8 is:
-- C3A4C3B6C3BC
--
Github repository Oracle-Patterns, path: /Installed/utl/raw/convert.plsql

Compare some 8-bit character sets

The following select statement uses utl_raw.convert in combination with utl_raw.cast_to_varchar2 to compare four 8-bit character sets:
with
   num255 as (
   --
   -- Number generator:
   --    Generate all numbers between 1 and 255
   --    Return the numbers in decimal and hexadecimal format.
   --
      select
         level                   dec,
         to_char(level, 'fm0X')  hex
      from
         dual connect by level <= 255
   ),
   numraw as (
   --
   -- Apply hextoraw() to create a raw from the numbers' hexadecimal representation:
   --
      select
         num255.dec,
         num255.hex,
         hextoraw(num255.hex) raw_
      from
         num255
   ),
   chars as (
   --
   -- This query is supposed to be on a database with character set AL32UTF8.
   -- Therefore, use utl_raw.convert to interpret the raw value in AL32UTF8 and
   -- convert it to a raw that corresponds to one of the four desired character sets.
   -- Use utl_raw.cast_to_varchar2 to create a varchar2 from the raw varsion.
   --
      select
         dec,
         hex,
      -- raw_,
         utl_raw.cast_to_varchar2(utl_raw.convert(raw_, 'al32utf8', 'we8mswin1252' )) we8mswin1252,
         utl_raw.cast_to_varchar2(utl_raw.convert(raw_, 'al32utf8', 'we8iso8859p1' )) we8iso8859p1,
         utl_raw.cast_to_varchar2(utl_raw.convert(raw_, 'al32utf8', 'we8iso8859p9' )) we8iso8859p9,
         utl_raw.cast_to_varchar2(utl_raw.convert(raw_, 'al32utf8', 'we8iso8859p15')) we8iso8859p15
      from
         numraw
    )
select
   *
from
   chars
where
--
--  Apply a filter to select specific characters.
--
-- we8mswin1252 <> we8iso8859p1
-- we8iso8859p1 <> we8iso8859p9
-- we8iso8859p9 <> we8iso8859p15
   1 = 1
;

See also

convert
utl_i18n.string_to_raw.
utl_raw

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758206647, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/installed/packages/utl/raw/api/convert/index(136): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78