Skip to main content

encode_with_dictionary

Function encode_with_dictionary 

Source
pub fn encode_with_dictionary(
    input: &[u8],
    dict: &Dictionary,
) -> Result<Vec<u16>, PreprocessError>
Expand description

Encodes input greedily (longest match first) using an existing Dictionary.

Useful when compressing new text with a fixed vocabulary such as assets/enwik9.voc.

ยงErrors

Returns PreprocessError::MissingByteSymbol if dict does not contain all 256 single-byte base entries required as fallback.