03 — Unicode¶
Ruby's String has Unicode's hard parts built in, as methods: segmentation into grapheme clusters, the four normalization forms, full case mapping and case folding. Ruby 4.0 carries the Unicode 17.0 tables. The traps are in the defaults beside them: length and reverse work in code points, == compares code points without normalizing, and casecmp is ASCII-only.
| Lesson | The one thing |
|---|---|
length counts code points |
and what reverse and [] do to a flag or an accent |
| Normalization is built in | two spellings of café, and unicode_normalize |
| Case mapping is full Unicode, with options instead of a locale | ß, :turkic, :fold, and the ASCII-only casecmp |