Search code examples
oracle-databasecharacter-encodingglobalization

Displaying whole ORACLE 8-bit CHARSETS in UNICODE


I maintain an Java EE web application against an eight bits charset oracle database.

The application will be used from abroad and I want to be able to check strings -for example with UNICODE regexps, and both from Java and from Javascript- to see if they fit into the database CHARSET.

One function in GDK -globalization developer kit- gives the equivalent Java name of the oracle charset -I think it was ISO-8859-15-. But I'm not certain the correspondence will be exact.

What I wanted is to display the whole charset -NOT ISO..., but the ORACLE one- char by char to use both from Java and Javascript, even to display the UNICODE points and to tell apart the control characters from printable ones.

There is a funcion in Oracle's GDK to that end?

Thank you.


Solution

  • I think I've found it! (Eureka!)

    A little JAVA JDBC program resulted in exactly the characters in ISO-8859-15 that are distintc to ISO-8859-1 (by the way, I've learned that ISO-8859-1 occupies from 0x00 to 0xff in UNICODE).

    Program output:

    CHR: 164 UNICODE: 8364 euro sign

    CHR: 166 UNICODE: 352

    CHR: 168 UNICODE: 353

    CHR: 180 UNICODE: 381

    CHR: 184 UNICODE: 382

    CHR: 188 UNICODE: 338

    CHR: 189 UNICODE: 339

    CHR: 190 UNICODE: 376

    Program code (not using GDK at all):

    NOTE: the statement "SELECT CHR(i using nchar_cs) FROM DUAL" just gave back the same numbers... WHY?

      for(int i=0; i<256; i++)
      {
        Statement select = con.createStatement();
        ResultSet result = select.executeQuery("select CHR(" + i +") from DUAL");
        while(result.next())
        {
          int unicodePoint = result.getString(1).codePointBefore(1);
          //int unicodePoint = result.getString(1).codePointAt(0);
          if (unicodePoint != i)
            System.out.println("CHR: " + i + "\tUNICODE: " + unicodePoint);
        }
        result.close();
        result = null;
        select.close();
        select = null;
      }