pypi / chardet
chardet
What changed in chardet 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-28.
8 breaking1 security1 deprecations1 new APIs and options2 performance4 behavior and defaults20 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initchardet 737 changes
Breaking changes 8
is_multibyte_cjk is the new name for the EncodingInfo field previously named is_multibyte.
Markup declarations follow the WHATWG prescan: comments and unrelated attributes no longer supply the charset, while quoted or spaced content charsets work.
Compiled builds now require both the mypyc and custom build hooks to be enabled.
Low-confidence rare-language winners yield to near-tied mainstream candidates; rare-language labels on inputs under 128 bytes need a 0.03 lead.
Statistical ties no longer resolve according to candidate enumeration order.
UTF-7 detection now requires the whole buffer to decode as UTF-7, and a lone shifted character must fall in a plausible script range.
The BOM stage recognizes the four UTF-7 signature prefixes when the rest of the buffer decodes as UTF-7.
Valid multi-byte UTF-8 now wins over a conflicting charset declaration.
Security 1
The cache is capped at 1024 entries because charset names can come from untrusted markup.
Deprecations 1
is_multibyte is deprecated with a DeprecationWarning and will be removed in 8.0; use is_multibyte_cjk instead.
New APIs and options 1
The new -m/--mime-type flag shows the MIME type next to the encoding.
Performance 2
Large max_bytes values no longer make detection slow; evidence gathering stops at a 256 KiB cap, while UTF-8 validation and the final decode still read the whole window. Default calls are unchanged.
Compiled wheels use a small Cython kernel alongside mypyc for bigram scoring; the pair is 4.7x faster than the pure wheel on CPython 3.14, with bit-identical output.
Behavior and default changes 4
Visual-order Hebrew is now detected.
Every bigram model was retrained on a refreshed, deduplicated corpus, changing the models used for detection.
Confusion-group resolution now uses per-occurrence votes, word-shape demotions, and an art-model exemption; tied pairs are compared only under language models both encodings have.
A new ANSI-art model supports detection of text-mode art encoded as cp437.
Fixes and other changes 20
The deprecated chardet.equivalences shim has been fixed.
Input cut exactly at the byte cap is no longer mistaken for the whole stream.
cp864 Arabic is trained on contextually shaped text in visual order, matching how real cp864 systems stored it.
Every answer now decodes the examined window under the returned encoding name, preventing confident detections that would fail when the rest of the window is decoded.
The ranking of detect_all() results has been fixed.
EBCDIC XML MIME types have been fixed.
Null-separated records like find -print0 output no longer come back as UTF-16-LE with Chinese as the language.
Cookie resolution now matches tokenize.detect_encoding, including when a line-2 cookie counts.
With prefer_superset=True, chardet no longer substitutes a code page that cannot decode the data and now respects include_encodings and exclude_encodings.
Language labels on Unicode text are less likely to favor accent-heavy languages; a French paragraph with a few accents no longer comes back as Hungarian.
Input cut exactly at the byte cap is no longer mistaken for the whole stream.
BOM-bearing UTF-32 is no longer detected as UTF-16 when max_bytes cuts a code unit.
Mostly-ASCII Windows-1252 and English text with a lone accented character no longer receive the cited incorrect encoding labels.
CPython 3.15, including its free-threaded build, is now supported.
When the winning candidate's only multi-byte evidence is an incomplete trailing sequence, a candidate that decodes the complete input wins; genuinely truncated data keeps its answer.
EBCDIC text is now visible to early pipeline stages, and the last two EBCDIC sibling misdetections are fixed.
Training normalization gaps that starved ISO-8859-16 and 26 pre-euro encodings at their distinguishing bytes are fixed.
Statistical scoring skips repeated-whitespace bigrams, fixing space-padded text and windows-1251 logs being misdetected.
Byte order for BOM-less UTF-16 is now chosen by decoding both ways and comparing text quality.
CP932 and CP949 promotion now fires when the reported name cannot decode the data but the superset can.