Skip to content

Commit c0e1ef0

Browse files
committed
Fix backwards count of Indic graphemes
1 parent 5cda4f4 commit c0e1ef0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

stdlib/public/core/StringGraphemeBreaking.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ extension _StringGuts {
390390
// If we're currently in an indic sequence (or if our lhs is a linking
391391
// consonant), then this check and everything underneath ensures that
392392
// we continue being in one and may check if this extend is a Virama.
393-
if state.isInIndicSequence || scalar1._isLinkingConsonant {
393+
if state.isInIndicSequence ||
394+
(!isBackwards && scalar1._isLinkingConsonant) {
394395
if y == .extend {
395396
let extendNormData = Unicode._NormData(scalar2, fastUpperbound: 0x300)
396397

validation-test/stdlib/String.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,13 @@ if #available(SwiftStdlib 5.6, *) {
23332333
let test10 = "\u{003F}\u{094D}\u{0924}" // 2
23342334
expectEqual(2, test10.count)
23352335
expectBidirectionalCount(2, test10)
2336+
2337+
#if _runtime(_ObjC)
2338+
let test11Foreign = NSString(string: "\u{930}\u{93e}\u{91c}\u{94d}") // 2
2339+
let test11 = test11Foreign as String
2340+
expectEqual(2, test11.count)
2341+
expectBidirectionalCount(2, test11)
2342+
#endif
23362343
}
23372344
}
23382345

0 commit comments

Comments
 (0)