cChardet is a high-speed universal character encoding detector implemented as a C extension for Python. It provides fast and accurate detection of text encoding, leveraging the underlying `uchardet` library (a port of Mozilla's `chardet`). The current stable version is 2.1.7, with alpha releases for 2.2.0 indicating ongoing development and support for newer Python versions.
pip install cchardetVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic character encoding detection using `cchardet.detect()` for a single byte string and `UniversalDetector` for streaming data. `detect()` returns a dictionary with 'encoding', 'confidence', and 'language'.
Ensure your Python environment meets the requirements of the specific `cchardet` version. For new projects, target Python 3.9+ with `cchardet` 2.1.7, or consider using the 2.2.x series for newer Python versions once stable.
If upgrading from pre-2.0.0 versions, thoroughly test your application's encoding detection behavior, especially with diverse input data, to ensure consistency and correctness.
Ensure you have a C compiler installed if you encounter build errors during `pip install`. For Windows, this typically means installing 'Build Tools for Visual Studio'. For Linux, 'build-essential' or similar packages. Consider using Docker or virtual environments with pre-built images if compilation is problematic.
Always inspect the `confidence` value in the returned dictionary. Implement logic to handle cases where confidence is low, such as attempting other detection methods, using a default encoding, or prompting the user.
No dependency data recorded yet.