@@ -1481,7 +1481,7 @@ SELECT 'x-y' = 'x_y' COLLATE level4; -- false
1481
1481
</sect3>
1482
1482
1483
1483
<sect3 id="icu-locale-examples">
1484
- <title>Examples</title>
1484
+ <title>Collation Settings Examples</title>
1485
1485
1486
1486
<variablelist>
1487
1487
<varlistentry id="collation-managing-create-icu-de-u-co-phonebk-x-icu">
@@ -1530,6 +1530,62 @@ SELECT 'x-y' = 'x_y' COLLATE level4; -- false
1530
1530
</variablelist>
1531
1531
</sect3>
1532
1532
1533
+ <sect3 id="icu-tailoring-rules">
1534
+ <title>ICU Tailoring Rules</title>
1535
+
1536
+ <para>
1537
+ If the options provided by the collation settings shown above are not
1538
+ sufficient, the order of collation elements can be changed with tailoring
1539
+ rules, whose syntax is detailed at <ulink
1540
+ url="https://unicode-org.github.io/icu/userguide/collation/customization/"></ulink>.
1541
+ </para>
1542
+
1543
+ <para>
1544
+ This small example creates a collation based on the root locale with a
1545
+ tailoring rule:
1546
+ <programlisting>
1547
+ <![CDATA[CREATE COLLATION custom (provider = icu, locale = 'und', rules = '&V << w <<< W');]]>
1548
+ </programlisting>
1549
+ With this rule, the letter <quote>W</quote> is sorted after
1550
+ <quote>V</quote>, but is treated as a secondary difference similar to an
1551
+ accent. Rules like this are contained in the locale definitions of some
1552
+ languages. (Of course, if a locale definition already contains the
1553
+ desired rules, then they don't need to be specified again explicitly.)
1554
+ </para>
1555
+
1556
+ <para>
1557
+ Here is a more complex example. The following statement sets up a
1558
+ collation named <literal>ebcdic</literal> with rules to sort US-ASCII
1559
+ characters in the order of the EBCDIC encoding.
1560
+
1561
+ <programlisting>
1562
+ <![CDATA[CREATE COLLATION ebcdic (provider = icu, locale = 'und',
1563
+ rules = $$
1564
+ & ' ' < '.' < '<' < '(' < '+' < \|
1565
+ < '&' < '!' < '$' < '*' < ')' < ';'
1566
+ < '-' < '/' < ',' < '%' < '_' < '>' < '?'
1567
+ < '`' < ':' < '#' < '@' < \' < '=' < '"'
1568
+ <*a-r < '~' <*s-z < '^' < '[' < ']'
1569
+ < '{' <*A-I < '}' <*J-R < '\' <*S-Z <*0-9
1570
+ $$);]]>
1571
+
1572
+ SELECT c
1573
+ FROM (VALUES ('a'), ('b'), ('A'), ('B'), ('1'), ('2'), ('!'), ('^')) AS x(c)
1574
+ ORDER BY c COLLATE ebcdic;
1575
+ c
1576
+ ---
1577
+ !
1578
+ a
1579
+ b
1580
+ ^
1581
+ A
1582
+ B
1583
+ 1
1584
+ 2
1585
+ </programlisting>
1586
+ </para>
1587
+ </sect3>
1588
+
1533
1589
<sect3 id="icu-external-references">
1534
1590
<title>External References for ICU</title>
1535
1591
0 commit comments