fn dec_surrogates(second: u8, third: u8, fifth: u8, sixth: u8) -> [u8; 4] {
    // Convert to a 32-bit code point.
    let s1 = dec_surrogate(second, third);
    let s2 = dec_surrogate(fifth, sixth);
    let c = 0x10000 + (((s1 - 0xD800) << 10) | (s2 - 0xDC00));
    //println!("{:0>8b} {:0>8b} {:0>8b} -> {:0>16b}", 0xEDu8, second, third, s1);
    //println!("{:0>8b} {:0>8b} {:0>8b} -> {:0>16b}", 0xEDu8, fifth, sixth, s2);
    //println!("-> {:0>32b}", c);
    assert!(0x010000 <= c && c <= 0x10FFFF);

    // Convert to UTF-8.
    // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    [0b1111_0000u8 | ((c & 0b1_1100_0000_0000_0000_0000) >> 18) as u8,
     TAG_CONT_U8   | ((c & 0b0_0011_1111_0000_0000_0000) >> 12) as u8,
     TAG_CONT_U8   | ((c & 0b0_0000_0000_1111_1100_0000) >>  6) as u8,
     TAG_CONT_U8   | ((c & 0b0_0000_0000_0000_0011_1111)      ) as u8]
}
/// Convert the bytes from a CESU-8 surrogate pair into a valid UTF-8
/// sequence.  Assumes input is valid.
Convert the bytes from a CESU-8 surrogate pair into a valid UTF-8
sequence.  Assumes input is valid.
Convert the bytes from a CESU - 8 surrogate pair into a valid UTF - 8 sequence . Assumes input is valid .
fn dec_surrogates(second: u8, third: u8, fifth: u8, sixth: u8) -> [u8; 4] {
    // Convert to a 32-bit code point.
    let s1 = dec_surrogate(second, third);
    let s2 = dec_surrogate(fifth, sixth);
    let c = 0x10000 + (((s1 - 0xD800) << 10) | (s2 - 0xDC00));
    //println!("{:0>8b} {:0>8b} {:0>8b} -> {:0>16b}", 0xEDu8, second, third, s1);
    //println!("{:0>8b} {:0>8b} {:0>8b} -> {:0>16b}", 0xEDu8, fifth, sixth, s2);
    //println!("-> {:0>32b}", c);
    assert!(0x010000 <= c && c <= 0x10FFFF);
    // Convert to UTF-8.
    // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    [0b1111_0000u8 | ((c & 0b1_1100_0000_0000_0000_0000) >> 18) as u8,
     TAG_CONT_U8   | ((c & 0b0_0011_1111_0000_0000_0000) >> 12) as u8,
     TAG_CONT_U8   | ((c & 0b0_0000_0000_1111_1100_0000) >>  6) as u8,
     TAG_CONT_U8   | ((c & 0b0_0000_0000_0000_0011_1111)      ) as u8]
}
fn dec_surrogates ( second : u8 , third : u8 , fifth : u8 , sixth : u8 ) -> [ u8 ; 4 ] { // Convert to a 32-bit code point. let s1 = dec_surrogate ( second , third ) ; let s2 = dec_surrogate ( fifth , sixth ) ; let c = 0x10000 + ( ( ( s1 - 0xD800 ) << 10 ) | ( s2 - 0xDC00 ) ) ; //println!("{:0>8b} {:0>8b} {:0>8b} -> {:0>16b}", 0xEDu8, second, third, s1); //println!("{:0>8b} {:0>8b} {:0>8b} -> {:0>16b}", 0xEDu8, fifth, sixth, s2); //println!("-> {:0>32b}", c); assert ! ( 0x010000 c c 0x10FFFF ) ; // Convert to UTF-8. // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx [ 0b1111_0000u8 | ( ( c & 0b1_1100_0000_0000_0000_0000 ) >> 18 ) as u8 , TAG_CONT_U8 | ( ( c & 0b0_0011_1111_0000_0000_0000 ) >> 12 ) as u8 , TAG_CONT_U8 | ( ( c & 0b0_0000_0000_1111_1100_0000 ) >> 6 ) as u8 , TAG_CONT_U8 | ( ( c & 0b0_0000_0000_0000_0011_1111 ) ) as u8 ] }
Convert the bytes from a CESU-8 surrogate pair into a valid UTF-8
sequence.
Convert the bytes from a CESU - 8 surrogate pair into a valid UTF - 8 sequence .
second
u8
third
u8
fifth
u8
sixth
u8
second
u8
third
u8
fifth
u8
sixth
u8