Skip to content

Commit 3d593f8

Browse files
committed
Fix state of reverse iterator after ZWJ
Fixes #14.
1 parent 6e53004 commit 3d593f8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/grapheme.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ impl<'a> DoubleEndedIterator for Graphemes<'a> {
344344
take_curr = false;
345345
break;
346346
},
347-
Zwj => match cat { // char to right is (GAZ|EBG)
348-
gr::GC_ZWJ => continue, // rule GB11: ZWJ x (GAZ|EBG)
347+
Zwj => match cat { // char to right is (GAZ|EBG)
348+
gr::GC_ZWJ => FindExtend, // rule GB11: ZWJ x (GAZ|EBG)
349349
_ => {
350350
take_curr = false;
351351
break;

src/test.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ fn test_graphemes() {
3030
&["\u{600}", "\u{20}", "\u{20}"]),
3131
];
3232

33-
for &(s, g) in TEST_SAME.iter() {
33+
pub const EXTRA_SAME: &'static [(&'static str, &'static [&'static str])] = &[
34+
// family emoji (more than two emoji joined by ZWJ)
35+
("\u{1f468}\u{200d}\u{1f467}\u{200d}\u{1f466}",
36+
&["\u{1f468}\u{200d}\u{1f467}\u{200d}\u{1f466}"]),
37+
];
38+
39+
for &(s, g) in TEST_SAME.iter().chain(EXTRA_SAME) {
3440
// test forward iterator
3541
assert!(UnicodeSegmentation::graphemes(s, true).eq(g.iter().cloned()));
3642
assert!(UnicodeSegmentation::graphemes(s, false).eq(g.iter().cloned()));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy