#[non_exhaustive]pub struct DecodeOptions<'a> {
pub declared: bool,
pub source_lang: Option<&'a str>,
pub limits: Limits,
pub lossy_after_utf8_bom: bool,
pub mark_before_legacy: bool,
}Expand description
How one text file is read. Build it with DecodeOptions::new (from the extraction options) or
DecodeOptions::with_limits, then DecodeOptions::declared for a format that declares its charset.
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.declared: boolThe format declares its charset in the file (HTML meta, XML declaration, PO Content-Type): honour a
declared legacy charset, and write the declaration back when the file is merged.
source_lang: Option<&'a str>The project’s source language, which picks the legacy code page of an undeclared non-UTF-8 file.
limits: LimitsThe limits the decoded text is checked against.
lossy_after_utf8_bom: boolA UTF-8 byte order mark followed by bytes that are not UTF-8 is read as UTF-8 with replacement characters (U+FFFD), as Localization OS does for plain text and subtitles. Off: such a file is refused.
mark_before_legacy: boolA UTF-8 byte order mark followed by bytes that are not UTF-8 is read as a mark, and the bytes after it as an
undeclared legacy file (Localization OS BOM read version 2, #799.4 / #800.4: its subtitle readers). The
envelope tag records the mark (;bom8), so a merge writes it back: before the code page’s bytes, or before
UTF-8 when the text is written as UTF-8. Off: the mark’s three bytes are read as code-page text.
Implementations§
Source§impl<'a> DecodeOptions<'a>
impl<'a> DecodeOptions<'a>
Sourcepub fn new(opts: &'a ExtractOptions) -> DecodeOptions<'a>
pub fn new(opts: &'a ExtractOptions) -> DecodeOptions<'a>
The options of one extraction: its source language and its limits.
Sourcepub fn with_limits(limits: Limits) -> DecodeOptions<'static>
pub fn with_limits(limits: Limits) -> DecodeOptions<'static>
No source language, not declared, these limits.
Sourcepub fn with_source_lang(self, lang: Option<&'a str>) -> Self
pub fn with_source_lang(self, lang: Option<&'a str>) -> Self
The source language that picks the code page of an undeclared legacy file.