]> gitweb.factorcode.org Git - factor.git/blob - basis/unicode/UCA/CollationTest.html
ba95e9527cfb73f1fa13eac44ced29798c2c37fb
[factor.git] / basis / unicode / UCA / CollationTest.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd"> 
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <meta http-equiv="Content-Language" content="en-us">
7 <link rel="stylesheet" href="http://www.unicode.org/reports/reports.css" type="text/css">
8 <title>UCA Conformance Tests</title>
9 </head>
10
11 <body>
12
13 <table class="header">
14   <tbody><tr>
15     <td class="icon"><a href="http://www.unicode.org">
16     <img alt="[Unicode]" src="http://www.unicode.org/webscripts/logo60s2.gif" align="middle" border="0" height="33" width="34"></a>&nbsp;&nbsp;<a class="bar" href="http://www.unicode.org/reports/tr10/">Unicode
17     Collation Algorithm</a></td>
18   </tr>
19   <tr>
20     <td class="gray">&nbsp;</td>
21   </tr>
22 </tbody></table>
23 <div class="body">
24   <h1>Unicode® Collation Algorithm<br>Conformance Tests</h1>
25   <h2 align="center">Version 13.0.0<br>2020-02-12</h2>
26 <p>The following files provide conformance tests for the Unicode Collation Algorithm
27   (<a href="http://www.unicode.org/reports/tr10/tr10-43.html">UTS #10: Unicode Collation Algorithm</a>).</p>
28   <ul>
29     <li>CollationTest_SHIFTED.txt</li>
30     <li>CollationTest_NON_IGNORABLE.txt</li>
31     <li>CollationTest_SHIFTED_SHORT.txt</li>
32     <li>CollationTest_NON_IGNORABLE_SHORT.txt</li>
33   </ul>
34   <p>These files are large, and thus packaged in zip format to save download time.</p>
35
36 <h2>Format</h2>
37   <p>There are four different files:</p>
38   <ul>
39     <li>The shifted vs non-ignorable files correspond to the two alternate
40       <a href="http://www.unicode.org/reports/tr10/tr10-43.html#Variable_Weighting">Variable Weighting</a> values.</li>
41     <li>The SHORT versions omit the comments, for more compact storage.</li>
42   </ul>
43 <p>The format is illustrated by the following example:</p>
44   <pre>0385 0021;  # (΅) GREEK DIALYTIKA TONOS  [0316 015D | 0020 0032 0020 | 0002 0002 0002 |]</pre>
45   <p>The part before the semicolon is the hex representation of a sequence of Unicode code points. 
46   After the hash mark is a comment. This comment is purely informational, and may change in the 
47   future. Currently it consists of the characters of the sequence in parentheses,
48   the name of the first code point, and a representation of 
49   the&nbsp; sort key for the sequence.</p>
50   <p>The sort key representation is in square brackets. It uses a vertical bar for the ZERO 
51   separator. Between the bars are the primary, secondary, tertiary, and quaternary weights (if any), 
52   in hex.</p>
53   <blockquote>
54     <table class="noborder" border="0" cellpadding="2" cellspacing="0">
55       <tbody><tr>
56         <th class="noborder" align="left" valign="top" width="1%"><b>Note:</b></th>
57         <td class="noborder" valign="top">The sort key is purely informational. UCA does <i>not</i> 
58         require the production of any particular sort key, as long as the results of comparisons 
59         match.</td>
60       </tr>
61     </tbody></table>
62   </blockquote>
63
64   <h2>Testing</h2>
65   <p>The files are designed so each line in the file will order as being greater than or equal to 
66   the previous one, when using the UCA and the
67   <a href="http://www.unicode.org/reports/tr10/tr10-43.html#Default_Unicode_Collation_Element_Table">Default
68   Unicode Collation Element Table</a>.
69   A test program can read in each line, compare it to 
70   the last line, and signal an error if order is not correct. The exact comparison that should be 
71   used is as follows:</p>
72   <ol>
73     <li>Read the next line.</li>
74     <li>Parse each sequence up to the semicolon, and convert it into a Unicode string.</li>
75     <li>Compare that string with the string on the previous line, according to the UCA 
76     implementation, with strength = identical level (using S3.10).</li>
77     <li>If the last string is greater than the current string, then stop with an error.</li>
78     <li>Continue to the next line (step 1).</li>
79   </ol>
80   <p>If there are any errors, then the UCA implementation is not compliant. </p>
81   <p>These files contain test cases that include ill-formed strings, with surrogate code points.
82   Implementations that do not weight surrogate code points the same way as reserved code points
83   may filter out such lines lines in the test cases, before testing for conformance.</p>
84   <blockquote>
85     <p><b>Note:</b> This test is only valid for an untailored DUCET table.</p>
86   </blockquote>
87
88   <h2>Migration</h2>
89   <h3>Tie-breaker</h3>
90   <p>Beginning with UCA 6.2,
91   the test data strings are compared with strength = identical,
92   using UCA S3.10 as a tie-breaker, which compares the NFD forms of the strings in code point order.
93   Before UCA 6.2, the test files did not use strength = identical,
94   and instead used as a tie-breaker the comparison of the unnormalized strings.<br>
95   Therefore, implementations which use the UCA test files to test
96   multiple versions of UCA need to use different tie-breaker comparisons
97   depending on the UCA version.</p>
98
99   <h3>Discontiguous contractions</h3>
100   <p>Test data files for UCA 6.1 and earlier versions were generated with code that
101   had a bug in the contraction matching.
102   In that code, matches for certain contractions of Tibetan characters were found
103   despite intervening combining marks,
104   so that some test cases were not in proper order according to the UCA and the DUCET.
105   UCA 6.2 test files omitted the relevant test cases.
106   For UCA 6.3, the test data generation code was fixed and those test cases were restored.</p>
107
108   <p>For example, in the defective test data generation code,
109   the strings 0FB2 0F80 0F71 0334 and 0F77 0334 compared equal.
110   (U+0F77 is the TIBETAN VOWEL SIGN VOCALIC RR.)
111   However, UCA processing with the DUCET will not find the contraction 0FB2 0F71 0F80:</p>
112   <ul>
113     <li>UCA Step 1 normalizes 0FB2 0F80 0F71 0334 to 0FB2 0334 0F71 0F80.</li>
114     <li>Step 2.1 only finds a match for S=0FB2.</li>
115     <li>S2.1.1 loops over each of the following three characters C,
116     but there is no table entry for any of those three S+C.
117     In particular, there is no DUCET mapping for 0FB2+0F71
118     (see <i><a href="http://www.unicode.org/reports/tr10/tr10-43.html#Well_Formed_DUCET">Tibetan and
119     Well-Formedness of DUCET</a></i>).</li>
120     <li>The loop exits without finding any match beyond S=0FB2.</li>
121   </ul>
122
123   <p>See “Also note that the Algorithm employs two distinct contraction matching methods:”
124   at the end of <i>Section 7.2,
125   <a href="http://www.unicode.org/reports/tr10/tr10-43.html#Step_2">Produce Collation Element Arrays</a></i>.</p>
126
127   <hr width="50%">
128   <p class="copyright">© 2020 Unicode, Inc. All Rights Reserved.
129   The Unicode Consortium makes no expressed or implied warranty 
130   of any kind, and assumes no liability for errors or omissions. No liability 
131   is assumed for incidental and consequential damages in connection with or arising 
132   out of the use of the information or programs contained or accompanying this 
133   technical report. The Unicode
134   <a href="http://www.unicode.org/copyright.html">Terms of Use</a> apply.
135   </p>
136   <p class="copyright">Unicode and the Unicode logo are trademarks 
137   of Unicode, Inc., and are registered in some jurisdictions.</p>
138 </div>
139
140 </body></html>