pub open spec fn encode_scalar(scalar: u32) -> Seq<u8>Expand description
recommends
is_scalar(scalar),{
if has_width_1_encoding(scalar) {
seq![leading_byte_width_1(scalar)]
} else if has_width_2_encoding(scalar) {
seq![leading_byte_width_2(scalar), last_continuation_byte(scalar)]
} else if has_width_3_encoding(scalar) {
seq![
leading_byte_width_3(scalar), second_last_continuation_byte(scalar),
last_continuation_byte(scalar),
]
} else {
seq![
leading_byte_width_4(scalar), third_last_continuation_byte(scalar),
second_last_continuation_byte(scalar), last_continuation_byte(scalar),
]
}
}The UTF-8 encoding of the given value, assuming that it is a Unicode scalar.