#[non_exhaustive]pub struct DecodedUtf16 {
pub text: String,
pub unpaired_surrogates: usize,
pub dangling_byte: bool,
}Expand description
A decoded UTF-16 string together with what decoding it cost.
text is always well-formed UTF-8 — every unpaired surrogate half is replaced with
U+FFFD — so a caller may ignore the rest. The remaining fields say what the replacement
concealed, because a decode that lost information should be able to report it rather
than hand back a plausible-looking string.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.text: StringThe decoded text. Unpaired surrogate halves appear as U+FFFD.
unpaired_surrogates: usizeHow many unpaired surrogate halves were replaced with U+FFFD in text.
dangling_byte: boolThe input had an odd length, so a trailing byte could not form a code unit and was dropped. Reported for the input as a whole, whatever the NUL policy — an odd-length UTF-16 field is a structural anomaly worth surfacing even when the dropped byte fell past a terminator.
Implementations§
Trait Implementations§
Source§impl Clone for DecodedUtf16
impl Clone for DecodedUtf16
Source§fn clone(&self) -> DecodedUtf16
fn clone(&self) -> DecodedUtf16
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more