Skip to content

feat: Upgrade to Unicode 18.0.0 - #184

Merged
Manishearth merged 1 commit into
unicode-rs:masterfrom
Martin005:unicode-18
Sep 17, 2026
Merged

Manishearth merged 1 commit into
unicode-rs:masterfrom
Martin005:unicode-18

Conversation

@Martin005

Copy link
Copy Markdown
Contributor

This PR updates Unicode support to version 18.0.0 (Unicode Standard Annex #29 in Unicode 18.0.0). See changes done in UAX#29 in Unicode 18.0.0 here.

Algorithmic (src/grapheme.rs)

  • Rewrite handle_incb_consonant for the new GB9c rule. The old rule required a preceding InCB=Consonant before the Linker sequence; the new rule only requires an InCB=Linker (with optional InCB=Extend) before the InCB=Consonant. The backward walk now simply skips extends, looks for a linker, and suppresses the break.

  • Fix next_boundary linker count tracking. Since Unicode 18, some InCB=Linker characters (U+1CF5, U+1CF6, U+11A3A) have gcb=Other instead of Extend/ZWJ. The old code reset the linker count before reaching the linker check. Now is_incb_linker is checked first.

  • Fix prev_boundary linker count tracking. Handle the case where a linker is encountered with count=0 (previously fell through to None).

Data generation (scripts/)

  • unicode.py: Relaxed check_incb_derivable to warn (not crash) when InCB=Linker characters exist outside Extend∪ZWJ. Fixed two pre-existing bugs in is_incb_linker generation: range upper bound used lo instead of hi, and .. instead of ..=.

  • unicode_gen_breaktests.py: Updated regex for Unicode 18 test data format (sot/eot markers changed from [0.2]/[0.3] to [1.0]/[2.0]).

Tests

  • Added unit tests for handle_incb_consonant (basic, no-linker, across-chunks) and is_incb_linker coverage of the three new
    Unicode 18 linkers.
  • Added test_grapheme_cursor_incb_consonant_chunked integration test verifying cursor-based chunked mode matches the iterator for all five GB9c test sequences.
  • Added EXTRA_DIFF entry for Linker+Extend+Consonant extended vs legacy behavior.

Implement GB9c rule change from Unicode Standard Annex unicode-rs#29:

simplify Indic conjunct break from
  `Consonant [Extend Linker]* Linker [Extend Linker]* × Consonant`
to
  `Linker Extend* × Consonant`

This also handles three new InCB=Linker characters (U+1CF5, U+1CF6,
U+11A3A) that have gcb categories other than Extend/ZWJ, requiring
fixes to the linker count tracking in next_boundary and prev_boundary.

@Manishearth Manishearth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks correct.

@Manishearth
Manishearth merged commit 346f36a into unicode-rs:master Sep 17, 2026
4 checks passed
@Martin005
Martin005 deleted the unicode-18 branch September 17, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants