[stdlib] Fix backwards count of Indic graphemes #41389
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When determining the grapheme boundaries of Indic sequences while walking backwards, there were some cases that were incorrectly being labeled as an Indic sequences.
For example, राज् is composed of:
[.linkingConsonant, .spacingMark, .linkingConsonant, .virama]
The rule defined by the CLDR here: https://github.com/unicode-org/cldr/tree/main/common/properties/segments
9.3) LinkingConsonant ExtCccZwj* Virama ExtCccZwj* × LinkingConsonant
was being incorrectly applied to the last two scalars when walking backwards, and as a result, the whole string was being counted as a singular grapheme instead of 2 (
\u{930}\u{93e}
and\u{91c}\u{94d}
)We have to at least be in an Indic sequence already when we see
(.linkingConsonant, .virama)
while walking backwards to be able to resolve any sort of state.Resolves: rdar://88893489 & rdar://88866287