charset-norm
Universal character encoding detector for Rust: a Rust implementation of charset_normalizer.
It decodes a payload with every supported code page, measures how noisy each result looks (chaos) and how well it matches known languages (coherence), and ranks the plausible encodings. Decoding reproduces CPython's codecs byte for byte (98 code pages, including the CJK and ISO-2022 families), so results agree with the Python package.
Usage
[]
= "4.0"
let payload = read?;
let results = from_bytes;
match results.best
Detection can be tuned and observed:
use ;
let options = DetectionOptions ;
let results = from_bytes_with;
The building blocks are public too: codecs (CPython-compatible decoders and
encoders), encoding (names, BOMs, declared charsets), mess, coherence
and unicode.
Features
log: forward detection diagnostics to thelogcrate throughcharset_norm::log::LogCrate.
License
MIT. Based on charset_normalizer by Ahmed TAHRI.