File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,17 @@ pub fn from_digit(num: u32, radix: u32) -> Option<char> {
363
363
}
364
364
}
365
365
366
+ fn is_combining_char ( c : char ) -> bool {
367
+ match c as u32 {
368
+ 0x0300 ..=0x036f |
369
+ 0x1ab0 ..=0x1aff |
370
+ 0x1dc0 ..=0x1dff |
371
+ 0x20d0 ..=0x20ff |
372
+ 0xfe20 ..=0xfe2f => true ,
373
+ _ => false
374
+ }
375
+ }
376
+
366
377
// NB: the stabilization and documentation for this trait is in
367
378
// unicode/char.rs, not here
368
379
#[ allow( missing_docs) ] // docs in libunicode/u_char.rs
@@ -451,8 +462,8 @@ impl CharExt for char {
451
462
'\r' => EscapeDefaultState :: Backslash ( 'r' ) ,
452
463
'\n' => EscapeDefaultState :: Backslash ( 'n' ) ,
453
464
'\\' | '\'' | '"' => EscapeDefaultState :: Backslash ( self ) ,
454
- c if is_printable ( c ) => EscapeDefaultState :: Char ( c ) ,
455
- c => EscapeDefaultState :: Unicode ( c . escape_unicode ( ) ) ,
465
+ _ if is_printable ( self ) && ! is_combining_char ( self ) => EscapeDefaultState :: Char ( self ) ,
466
+ _ => EscapeDefaultState :: Unicode ( self . escape_unicode ( ) ) ,
456
467
} ;
457
468
EscapeDebug ( EscapeDefault { state : init_state } )
458
469
}
Original file line number Diff line number Diff line change 76
76
#![ feature( custom_attribute) ]
77
77
#![ feature( doc_cfg) ]
78
78
#![ feature( doc_spotlight) ]
79
+ #![ cfg_attr( stage0, feature( dotdoteq_in_patterns) ) ]
79
80
#![ feature( fn_must_use) ]
80
81
#![ feature( fundamental) ]
81
82
#![ feature( i128_type) ]
Original file line number Diff line number Diff line change @@ -181,6 +181,7 @@ fn test_escape_debug() {
181
181
assert_eq ! ( string( '\u{ff}' ) , "\u{ff} " ) ;
182
182
assert_eq ! ( string( '\u{11b}' ) , "\u{11b} " ) ;
183
183
assert_eq ! ( string( '\u{1d4b6}' ) , "\u{1d4b6} " ) ;
184
+ assert_eq ! ( string( '\u{301}' ) , "\\ u{301}" ) ; // combining character
184
185
assert_eq ! ( string( '\u{200b}' ) , "\\ u{200b}" ) ; // zero width space
185
186
assert_eq ! ( string( '\u{e000}' ) , "\\ u{e000}" ) ; // private use 1
186
187
assert_eq ! ( string( '\u{100000}' ) , "\\ u{100000}" ) ; // private use 2
You can’t perform that action at this time.
0 commit comments