File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -494,6 +494,7 @@ pub fn escape_bytes<W>(wr: &mut W, bytes: &[u8]) -> Result<()>
494494 try!( wr. write_all ( b"\" " ) ) ;
495495
496496 let mut start = 0 ;
497+ let mut last_byte_was_c2 = false ;
497498
498499 for ( i, byte) in bytes. iter ( ) . enumerate ( ) {
499500 let escaped = match * byte {
@@ -515,6 +516,21 @@ pub fn escape_bytes<W>(wr: &mut W, bytes: &[u8]) -> Result<()>
515516
516517 continue ;
517518 } ,
519+ b'\x80' ... b'\x9F' if last_byte_was_c2 => {
520+ if start < ( i - 1 ) {
521+ try!( wr. write_all ( & bytes[ start..( i - 1 ) ] ) ) ;
522+ }
523+
524+ try!( write ! ( wr, "\\ u{:04X}" , * byte) ) ;
525+
526+ start = i + 1 ;
527+
528+ continue ;
529+ } ,
530+ b'\xC2' => {
531+ last_byte_was_c2 = true ;
532+ continue ;
533+ } ,
518534 _ => { continue ; }
519535 } ;
520536
You can’t perform that action at this time.
0 commit comments