https://developer.aliyun.com/article/72935

标签

PostgreSQL , 10.0 , International Components for Unicode , ICU , collate , 国际化


背景

ICU是一个成熟的,被广泛使用的跨平台一致性全球化支持库。使用没有任何限制的开源许可,可以被商业、开源软件随意使用。

ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software applications.
ICU is widely portable and gives applications the same results on all platforms and between C/C++ and Java software. ICU is released under a nonrestrictive open source license that is suitable for use with both commercial software and with other open source or free software.

ICU的好处是与UNICODE标准最为贴近,而且可以使用ICU,软件可以做到跨平台保持一致性(只要是在ICU支持的平台中)。

ICU支持的功能如下,包括unicode和文本的转换,本土化的排序、时间日期格式支持,时区换算,规则表达式的unicode支持,等等。

Code Page Conversion: Convert text data to or from Unicode and nearly any other character set or encoding. ICU's conversion tables are based on charset data collected by IBM over the course of many decades, and is the most complete available anywhere.  

Collation: Compare strings according to the conventions and standards of a particular language, region or country. ICU's collation is based on the Unicode Collation Algorithm plus locale-specific comparison rules from the Common Locale Data Repository, a comprehensive source for this type of data.  

Formatting: Format numbers, dates, times and currency amounts according the conventions of a chosen locale. This includes translating month and day names into the selected language, choosing appropriate abbreviations, ordering fields correctly, etc. This data also comes from the Common Locale Data Repository.  

Time Calculations: Multiple types of calendars are provided beyond the traditional Gregorian calendar. A thorough set of timezone calculation APIs are provided.  

Unicode Support: ICU closely tracks the Unicode standard, providing easy access to all of the many Unicode character properties, Unicode Normalization, Case Folding and other fundamental operations as specified by the Unicode Standard.  

Regular Expression: ICU's regular expressions fully support Unicode while providing very competitive performance.  

Bidi: support for handling text containing a mixture of left to right (English) and right to left (Arabic or Hebrew) data.  

Text Boundaries: Locate the positions of words, sentences, paragraphs within a range of text, or identify locations that would be suitable for line wrapping when displaying the text.

PostgreSQL 以前的全球化是通过glibc库来支持,受到glibc版本的影响,在更换平台时,可能影响排序或者本土化的结果。(例如windows, linux, freebsd等跨平台使用时)。

10.0开始,支持ICU了,在安装PG软件的机器上安装好ICU库,同时在configure时打开--with-icu,就可以使用ICU4C了。

pg_collation新增了一个字段collprovider表示libc或者icu. 增加一个collversion字段,记录当时使用的ICU版本,run time时检查,确保版本一致。

ICU support  

Add a column collprovider to pg_collation that determines which library
provides the collation data. The existing choices are default and libc,
and this adds an icu choice, which uses the ICU4C library. The pg_locale_t type is changed to a union that contains the
provider-specific locale handles. Users of locale information are
changed to look into that struct for the appropriate handle to use. Also add a collversion column that records the version of the collation
when it is created, and check at run time whether it is still the same.
This detects potentially incompatible library upgrades that can corrupt
indexes and other structures. This is currently only supported by
ICU-provided collations. initdb initializes the default collation set as before from the
`locale-a` output but also adds all available ICU locales with a "-x-icu"
appended. Currently, ICU-provided collations can only be explicitly named
collations. The global database locales are still always libc-provided. ICU support is enabled by configure --with-icu. Reviewed-by: Thomas Munro <thomas.munro@enterprisedb.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>

例子

  11 CREATE TABLE collate_test1 (
12 a int,
13 b text COLLATE "en-x-icu" NOT NULL
14 );
15
16 \d collate_test1
17
18 CREATE TABLE collate_test_fail (
19 a int,
20 b text COLLATE "ja_JP.eucjp-x-icu"
21 );
22
23 CREATE TABLE collate_test_fail (
24 a int,
25 b text COLLATE "foo-x-icu"
26 );
27
28 CREATE TABLE collate_test_fail (
29 a int COLLATE "en-x-icu",
30 b text
31 );
32
33 CREATE TABLE collate_test_like (
34 LIKE collate_test1
35 );
36 92 -- constant expression folding
93 SELECT 'bbc' COLLATE "en-x-icu" > 'äbc' COLLATE "en-x-icu" AS "true";
94 SELECT 'bbc' COLLATE "sv-x-icu" > 'äbc' COLLATE "sv-x-icu" AS "false";
95
96 -- upper/lower
97
98 CREATE TABLE collate_test10 (
99 a int,
100 x text COLLATE "en-x-icu",
101 y text COLLATE "tr-x-icu"
102 );

这个patch的讨论,详见邮件组,本文末尾URL。

PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。

参考

https://wiki.postgresql.org/wiki/Todo:ICU

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=eccfef81e1f73ee41f1d8bfe4fa4e80576945048

http://site.icu-project.org/

[转帖]PostgreSQL 10.0 preview 功能增强 - 国际化功能增强,支持ICU(International Components for Unicode)的更多相关文章

  1. PostgreSQL 10.0 preview 性能增强 - 分区表性能增强(plan阶段加速)

    标签 PostgreSQL , 10.0 , 分区表 , 子表 , 元信息搜索性能增强 背景 PostgreSQL 10.0 增强了分区表的子表搜索性能,对于涉及分区表包含子表特别多的QUERY,可以 ...

  2. PostgreSQL 10.0 preview 功能增强

    https://yq.aliyun.com/users/1384833841157402?spm=5176.100239.blogrightarea51131.3.yI7e9d

  3. PostgreSQL 10.0 压缩版的 pgAdmin 不能用的问题

    PostgreSQL终于发布10.0正式版了!下载压缩版的更新了一下本机的版本,然后打开pgAdmin的时候总是报错“The application server could not be conta ...

  4. [转帖]Windows 10 部分早期版本已完全停止技术支持服务

    Windows 10 部分早期版本已完全停止技术支持服务 2019-4-12 01:27| 发布者: cjy__05| 查看: 10186| 评论: 47|来自: pcbeta 收藏分享 转帖来源:h ...

  5. 告别编译运行 ---- Android Studio 2.0 Preview发布Instant Run功能

    以往的Android开发有一个头疼的且拖慢速度的问题,就是你每改一行代码要想看到结果必须要编译运行到手机或者模拟器上,而且需要从头(可能是登录界面)一直点击到你修改的界面为止.开发一个完整的Andro ...

  6. [Android Pro] 告别编译运行 ---- Android Studio 2.0 Preview发布Instant Run功能

    reference to : http://www.cnblogs.com/soaringEveryday/p/4991563.html 以往的Android开发有一个头疼的且拖慢速度的问题,就是你每 ...

  7. VMWare Workstation 10.0 Preview CN

    What's New in the VMware Workstation Technology Preview July 2013 The VMware Workstation team is exc ...

  8. PostgreSQL 10首个测试版本发布

    mysql 从5.7到8.0,pg从9.6到10,干起来了.. PostgreSQL 10 的首个测试版发布了,此版本包含 PostgreSQL 10 最终将提供的所有功能的预览.当然,有些细节将在最 ...

  9. [翻译] .NET Core 3.0 Preview 9 发布

    原文: Announcing .NET Core 3.0 Preview 9 今天,我们宣布推出 .NET Core 3.0 Preview 9.就像 Preview 8 一样,我们专注于打磨 .NE ...

  10. .NET Core 3.0 Preview 9 发布

    翻译自官方博客 今天,我们宣布推出.NET Core 3.0 Preview 9.就像预览版8一样,我们专注打磨最终版本的.NET Core 3.0,而不是添加新功能.如果这些最终版本看起来不像早期预 ...

随机推荐

  1. APM市场冰火两重天,或许只是行业无处安放的焦虑

    近两年来,无论从国内还是到国外,市场出现一种APM批判的论调,甚至有"传统APM已经落后"的个别声音出现. 可放眼望去,国外主流APM厂商如:DATADOG. Dynatrace. ...

  2. Spring表达式语言(SPEL)学习(03)

    rootObject 在表达式中直接写name和getName(),这时候Expression是无法解析的,因为其不知道name和getName()对应什么意思 @Test public void t ...

  3. JVM学习-程序编译与优化

    原文链接:https://gaoyubo.cn/blogs/89d6d9be.html 一.前端编译与优化 Java技术下讨论"编译期"需要结合具体上下文语境,因为它可能存在很多种 ...

  4. 基于DAYU的实时作业开发,分分钟搭建企业个性化推荐平台

    摘要:搭建这个平台最费时耗力的事莫过于对批.流作业的编排,作业组织管理以及任务调度了.但是这一切,用DAYU的数据开发功能几个任务可通通搞定. 大多数电商类企业都会搭建自己的个性化推荐系统,利用自己拥 ...

  5. 几款Java开发者必备常用的工具,准点下班不在话下

    摘要:一问一答的形式轻松学习掌握java工具. 以一问一答的形式学习java工具 Q:检查内存泄露的工具有?A: jmap生成dump转储文件,jhat可视化查看. Q:某进程CPU使用率一直占满,用 ...

  6. 如何做好分支管理,保证高效CI/CD?

    摘要:一文讲述git分支管理策略. 本文分享自华为云社区<如何做好分支管理,保证高效CICD?>,作者:华为云PaaS服务小智. 引言 CI/CD是DevOps 的基础核心,做好CI/CD ...

  7. 云图说|华为云自研云数据库GaussDB NoSQL,兼容多款NoSQL接口的数据库服务

    摘要:云数据库GaussDB NoSQL是一款基于计算存储分离架构的分布式多模NoSQL数据库服务,兼容多款nosql接口,在灵活弹性.快速扩展方面做到了极致. 本文分享自华为云社区<云图说|华 ...

  8. 对不起,你做的 A/B 实验都是错的——火山引擎 DataTester 科普

    DataTester 是火山引擎数智平台旗下产品,能基于先进的底层算法,提供科学分流能力和智能的统计引擎,支持多种复杂的 A/B 实验类型.DataTester 深度耦合推荐.广告.搜索.UI.产品功 ...

  9. 十分钟读懂火山引擎 DataLeap 数据治理实践

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 日前,火山引擎数智平台 VeDI 直播活动「超话数据」在线举办,来自火山引擎 DataLeap 数据产品专家从数据 ...

  10. 2014年第五届蓝桥杯【C++省赛B组】

    第一题:啤酒和饮料 啤酒每罐2.3元,饮料每罐1.9元.小明买了若干啤酒和饮料,一共花了82.3元. 我们还知道他买的啤酒比饮料的数量少,请你计算他买了几罐啤酒. 注意:答案是一个整数.请通过浏览器提 ...