Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to find a character's codepoint

J. Fuda-OracleAug 23 2011 — edited Aug 25 2011
Hi,

Is there an Oracle supplied function for finding a character's codepoint value (either in decimal or hex)? I.e. given a character like 'Æ' (U+00C6) I'd like a function that returns either 198 or 'C6'.

The ASCII() function is the closest thing I could find but it returns varied, and rather unhelpful decimal representations of the character, not its codepoint. E.g.
-- on a db with NLS_CHARACTERSET and NLS_NCHAR_CHARACTERSET set to UTF8

SQL> select ascii('Æ') from dual ;

ASCII('?')
----------
  15712189

SQL>
SQL> select ascii( unistr('\00C6') ) from dual ;

ASCII(UNISTR('\00C6'))
----------------------
                 50054

-- on a db with NLS_CHARACTERSET set to AL32UTF8 and NLS_NCHAR_CHARACTERSET set to AL16UTF16

SQL> select ascii('Æ') from dual ;

ASCII('Æ')
----------
  14844057

SQL> select ascii( unistr('\00C6') ) from dual ;

ASCII(UNISTR('\00C6'))
----------------------
                   198
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2011
Added on Aug 23 2011
6 comments
8,920 views