Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/huge-banks-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"unicode-segmenter": patch
---

Fix G9Bc rule; `ZWNJ`(InCB=None) handling was missing. Thanks to @spaceemotion for reporting this.
9 changes: 6 additions & 3 deletions src/grapheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ export function* graphemeSegments(input) {
if (!consonant && catBefore === 0) {
consonant = isIndicConjunctConsonant(_hd);
}
if (consonant && catAfter === 3) {
linker = linker
if (consonant && (catAfter === 3 || catAfter === 14)) {
// ZWNJ(U+200C) has InCB=None, it should break the GB9c pattern
linker = cp !== 0x200C && (
linker
|| cp === 0x094D // Devanagari Sign Virama
|| cp === 0x09CD // Bengali Sign Virama
|| cp === 0x0A4D // Gurmukhi Sign Virama
Expand All @@ -188,7 +190,8 @@ export function* graphemeSegments(input) {
|| cp === 0x1193E // Dives Akuru Virama
|| cp === 0x11A47 // Zanabazar Square Subjoiner
|| cp === 0x11A99 // Soyombo Subjoiner
|| cp === 0x11F42; // Kawi Conjoiner
|| cp === 0x11F42 // Kawi Conjoiner
);
} else {
linker = false;
}
Expand Down
27 changes: 27 additions & 0 deletions test/grapheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,33 @@ test('counterexamples', async t => {
'क्‍त',
'് ',
'्क',
'গ্‌ডু',
'স্ট্‌মা',
'আপি',
'স্ট্‌মা',
'ল্‌জ্ব',
'এবং',
'ল্‌ছ',
' ক',
' വ',
' ക',
' വൃ',
' പു',
' യ',
' പോ',
' ജോ',
' നീ',
'എന്നാ',
'ഡ്‌ഢി',
'ഇനി',
'ഉദ്യോ',
' താ',
' ദു',
' ബു',
'ഒര',
' जा',
' କା',
' ଶ୍ୟା',
];

for (let counter of counterExamples) {
Expand Down
Loading