以 UNICODE 显示整个 ORACLE 8 位字符集

发布于 2024-12-21 21:00:02 字数 390 浏览 4 评论 0原文

我根据八位字符集 Oracle 数据库维护一个 Java EE Web 应用程序。

该应用程序将在国外使用,我希望能够检查字符串 - 例如使用 UNICODE 正则表达式,以及来自 Java 和 Javascript 的字符串 - 以查看它们是否适合数据库 CHARSET。

GDK(全球化开发工具包)中的一个函数给出了 oracle 字符集的等效 Java 名称(我认为它是 ISO-8859-15)。但我不确定对应关系是否准确。

我想要的是显示整个字符集 - 不是 ISO...,而是 ORACLE 一个字符一个字符地使用 Java 和 Javascript,甚至显示 UNICODE 点并区分控制字符和可打印字符。

Oracle的GDK中有一个函数可以达到这个目的吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无可置疑 2024-12-28 21:00:02

我想我已经找到了! (尤里卡!)

一个小的 JAVA JDBC 程序产生了 ISO-8859-15 中与 ISO-8859-1 不同的字符(顺便说一句,我了解到 ISO-8859-1 占用从 0x00 到 0xff 的字符)统一码)。

程序输出:

CHR: 164 UNICODE: 8364 欧元符号

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统一码: 376

程序代码(根本不使用 GDK):

注意:语句“SELECT CHR(i using nchar_cs) FROM DUAL”只是返回相同的数字...为什么?

  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;
  }

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;
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文