Skip to content

[stdlib] Fix backwards count of Indic graphemes #41389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2022

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Feb 15, 2022

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

@stephentyrone
Copy link
Contributor

@swift-ci please test

@Azoy
Copy link
Contributor Author

Azoy commented Feb 16, 2022

@swift-ci please test

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

LGTM

Any chance to stick NonContigNSString in the unit test suite so it can be shared across test files?

@Azoy Azoy merged commit 27e6241 into swiftlang:main Mar 14, 2022
@Azoy Azoy deleted the fix-indic-sequences branch March 14, 2022 19:08
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.

3 participants