@@ -147,8 +147,8 @@ enum GraphemeState {
147
147
// The codepoint after is a Regional Indicator Symbol, so a boundary iff
148
148
// it is preceded by an even number of RIS codepoints. (GB12, GB13)
149
149
Regional ,
150
- // The codepoint after is in the E_Modifier category, so whether it's a boundary
151
- // depends on pre-context according to GB10 .
150
+ // The codepoint after is Extended_Pictographic,
151
+ // so whether it's a boundary depends on pre-context according to GB11 .
152
152
Emoji ,
153
153
}
154
154
@@ -239,11 +239,7 @@ fn check_pair(before: GraphemeCat, after: GraphemeCat) -> PairResult {
239
239
( _, GC_ZWJ ) => NotBreak , // GB9
240
240
( _, GC_SpacingMark ) => Extended , // GB9a
241
241
( GC_Prepend , _) => Extended , // GB9b
242
- ( GC_E_Base , GC_E_Modifier ) => NotBreak , // GB10
243
- ( GC_E_Base_GAZ , GC_E_Modifier ) => NotBreak , // GB10
244
- ( GC_Extend , GC_E_Modifier ) => Emoji , // GB10
245
- ( GC_ZWJ , GC_Glue_After_Zwj ) => NotBreak , // GB11
246
- ( GC_ZWJ , GC_E_Base_GAZ ) => NotBreak , // GB11
242
+ ( GC_ZWJ , GC_Extended_Pictographic ) => Emoji , // GB11
247
243
( GC_Regional_Indicator , GC_Regional_Indicator ) => Regional , // GB12, GB13
248
244
( _, _) => Break , // GB999
249
245
}
@@ -415,10 +411,17 @@ impl GraphemeCursor {
415
411
416
412
fn handle_emoji ( & mut self , chunk : & str , chunk_start : usize ) {
417
413
use tables:: grapheme as gr;
418
- for ch in chunk. chars ( ) . rev ( ) {
414
+ let mut iter = chunk. chars ( ) . rev ( ) ;
415
+ if let Some ( ch) = iter. next ( ) {
416
+ if gr:: grapheme_category ( ch) != gr:: GC_ZWJ {
417
+ self . decide ( true ) ;
418
+ return ;
419
+ }
420
+ }
421
+ for ch in iter {
419
422
match gr:: grapheme_category ( ch) {
420
423
gr:: GC_Extend => ( ) ,
421
- gr:: GC_E_Base | gr :: GC_E_Base_GAZ => {
424
+ gr:: GC_Extended_Pictographic => {
422
425
self . decide ( false ) ;
423
426
return ;
424
427
}
@@ -484,7 +487,7 @@ impl GraphemeCursor {
484
487
let mut need_pre_context = true ;
485
488
match self . cat_after . unwrap ( ) {
486
489
gr:: GC_Regional_Indicator => self . state = GraphemeState :: Regional ,
487
- gr:: GC_E_Modifier => self . state = GraphemeState :: Emoji ,
490
+ gr:: GC_Extended_Pictographic => self . state = GraphemeState :: Emoji ,
488
491
_ => need_pre_context = self . cat_before . is_none ( ) ,
489
492
}
490
493
if need_pre_context {
0 commit comments