The Unicode Collation Algorithm (UTS #10) and CLDR locale tailorings in Zig: sort text the way people expect rather than by code point.

Measure section 10.1.6's Hangul problem instead of postponing it

The four tailored methods for the trailing weights problem were on the "deliberately later" list. They are not implemented, and the reason turns out not to be "later": CLDR does not implement them either, and doing so would mean disagreeing with ICU. Syllables are decomposed to jamo as S1.1 requires, so the problem is reachable. All four methods turn on giving the trailing consonants a weight above every other script, so that `L1V1T1` outranks `L1V1Xa` for any following character. CLDR's root does not: its leading consonants run 0x4771..0x47ED, vowels 0x47EF..0x4835, trailing consonants 0x484D..0x48A4, and then Hiragana begins at 0x48D6 with Han derived above 0xFB40. So this library orders that section's own shapes L1L2V1 < 가 < 가a < 가가 < L1V1V2 < 각 < 각a < 각一 < 가一 with `가一` last: a syllable followed by a Han ideograph outranks the same syllable with a trailing consonant, where Korean dictionary order compares syllable by syllable and would have it the other way round. `L1L2V1` first is the same problem from the other end -- the data method would make `L1L2` a contraction, and without one the second leading consonant is compared against a vowel and wins. ICU gives the same order, and now says so on every run. Those shapes are in the oracle's root corpus: the precomposed forms beside the decomposed ones, each syllable alone and followed by a character from a script below Hangul and one above. The root corpus went from 496 comparisons to 1,035 and agrees in all nine modes. Nothing in this project compared a jamo sequence against what followed it before, because every corpus entry is one code point or one of a tailoring's own sequences -- which is precisely the shape the trailing weights problem cannot take. That gap was hidden by a surprise about Korean. `ko.xml`'s `standard` collation tailors no Hangul at all: it is 2,212 `&<syllable><<*<homophones>` chains ordering *Hanja* by Korean reading, which is why the corpus is ideographs and why its 28,452,196 comparisons say nothing about jamo. The conjoining jamo in that file are all in its `search` and `searchjl` collations, which are for matching rather than sorting and are not compiled. So how Hangul sorts here is the root table's answer and no tailoring's, and the root corpus is where the shapes belong. There is also a test pinning that order, since DESIGN.md now states it, and one asserting the precomposed syllables weigh exactly what their decompositions do -- which is what makes the anomaly a property of the weights rather than of how the text was written. Cited as section 10.1.5 throughout before this; 10.1.5 is Reserved Weights and Hangul Collation is 10.1.6. Verified: the ICU oracle at 0 differences in all nine modes, both conformance suites unchanged, 104,000 fuzz inputs with no findings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>


Author jcollie.dev
Co-author Claude Opus 5 (1M context) Date Commit Parent 151a24a7
+180 -12
4 changed files
+180 -12
4 changed files