chardet
chardet 7 is a ground-up, 0BSD-licensed rewrite of chardet. Same package name, same public API — drop-in replacement for chardet 5.x/6.x, just much faster…
Official Documentation ↗v5.2.0. Check the official docs for the latest API surface.Installation
pip install chardetMethods
No methods match this filter.
Overview
chardet 7 is a ground-up, 0BSD-licensed rewrite of chardet. Same package name, same public API — drop-in replacement for chardet 5.x/6.x, just much faster and more accurate.
API reference status
This page lists only entry points that appear verbatim in the official README examples: chardet.detect, chardet.detect_all, encode, round. Parameter and return types are not given by the official README, so signatures are marked unverified.
Verification notes
- Official source: https://github.com/chardet/chardet
- Evidence: https://cdn.jsdelivr.net/gh/chardet/chardet@latest/README.md
- Checked on 2026-11-04 by
scripts/phase11/build-api-profiles.mjs
Errors
The official API reference declares the following error types:
TypeError(raise TypeError(输入不是 bytes/bytearray 时抛出)) — official text: “ raise TypeError( f“Expected object of type bytes or bytearray, got: {type(byte_str)}” )” (source: https://github.com/chardet/chardet/blob/5.2.0/chardet/__init__.py, fetched 2026-11-08T17:41:29+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T17:41:29+08:00 via PowerShell Invoke-WebRequest 下载官方仓库 5.2.0 tag 的 chardet/init.py(raw.githubusercontent.com/chardet/chardet/5.2.0),Grep 提取函数定义与 raise 语句;WebFetch https://chardet.readthedocs.io/en/latest/usage.html 交叉核对 detect/detect_all 用法.
chardet.detect→ signature from https://github.com/chardet/chardet/blob/5.2.0/chardet/__init__.py; official text: “def detect( byte_str: Union[bytes, bytearray], should_rename_legacy: bool = False ) -> ResultDict: “”” Detect the encoding of the given byte string.”chardet.detect_all→ signature from https://github.com/chardet/chardet/blob/5.2.0/chardet/__init__.py; official text: “def detect_all( byte_str: Union[bytes, bytearray], ignore_threshold: bool = False, should_rename_legacy: bool = False, ) -> List[ResultDict]: “”” Detect all the possible encodings of the given byte string.”
FAQ
- What does chardet do?
- chardet 7 is a ground-up, 0BSD-licensed rewrite of chardet.
- How do I install chardet?
- Run `pip install chardet`.
- Where can I verify the API details?
- Official repository/documentation: https://github.com/chardet/chardet. Checked on 2026-11-04; signatures and return values not stated in the official README are marked unverified.
Report a problem with this API docOpens a pre-filled issue on GitHub.