cchardet 2.4.0


pip install cchardet

  Latest version

Released: Oct 11, 2026

Project Links

Meta
Author: PyYoshi
Requires Python: >=3.11

Classifiers

Programming Language
  • Python :: 3
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: 3.15

Topic
  • Software Development :: Libraries

cChardet

PyPI version Run tests Build Wheels

cChardet is a high-speed universal character encoding detector built on the PyYoshi/uchardet fork, which tracks upstream uchardet.

Python support

cChardet supports CPython 3.11 through 3.15, including the free-threaded CPython 3.14 and 3.15 builds. Each version is tested on Linux and Windows on both x86-64 and arm64, and on macOS on Apple silicon.

Development

Install uv, clone this repository with its submodules, then create the locked development environment and run the checks:

git submodule update --init --recursive
uv sync --locked
make check

Build and validate the source distribution and wheel with:

uv build
uv run twine check dist/*

Supported Languages/Encodings

  • International (Unicode)
    • UTF-8
    • UTF-16BE / UTF-16LE
    • UTF-32BE / UTF-32LE / X-ISO-10646-UCS-4-34121 / X-ISO-10646-UCS-4-21431
  • Arabic
    • ISO-8859-6
    • WINDOWS-1256
  • Bulgarian
    • ISO-8859-5
    • WINDOWS-1251
  • Chinese
    • ISO-2022-CN
    • BIG5
    • EUC-TW
    • GB18030
    • HZ-GB-2312
  • Croatian:
    • ISO-8859-2
    • ISO-8859-13
    • ISO-8859-16
    • Windows-1250
    • IBM852
    • MAC-CENTRALEUROPE
  • Czech
    • Windows-1250
    • ISO-8859-2
    • IBM852
    • MAC-CENTRALEUROPE
  • Danish
    • ISO-8859-1
    • ISO-8859-15
    • WINDOWS-1252
  • English
    • ASCII
  • Esperanto
    • ISO-8859-3
  • Estonian
    • ISO-8859-4
    • ISO-8859-13
    • ISO-8859-13
    • Windows-1252
    • Windows-1257
  • Finnish
    • ISO-8859-1
    • ISO-8859-4
    • ISO-8859-9
    • ISO-8859-13
    • ISO-8859-15
    • WINDOWS-1252
  • French
    • ISO-8859-1
    • ISO-8859-15
    • WINDOWS-1252
  • German
    • ISO-8859-1
    • WINDOWS-1252
  • Greek
    • ISO-8859-7
    • WINDOWS-1253
  • Hebrew
    • ISO-8859-8
    • WINDOWS-1255
  • Hungarian:
    • ISO-8859-2
    • WINDOWS-1250
  • Irish Gaelic
    • ISO-8859-1
    • ISO-8859-9
    • ISO-8859-15
    • WINDOWS-1252
  • Italian
    • ISO-8859-1
    • ISO-8859-3
    • ISO-8859-9
    • ISO-8859-15
    • WINDOWS-1252
  • Japanese
    • ISO-2022-JP
    • SHIFT_JIS
    • EUC-JP
  • Korean
    • ISO-2022-KR
    • EUC-KR / UHC
  • Lithuanian
    • ISO-8859-4
    • ISO-8859-10
    • ISO-8859-13
  • Latvian
    • ISO-8859-4
    • ISO-8859-10
    • ISO-8859-13
  • Maltese
    • ISO-8859-3
  • Polish:
    • ISO-8859-2
    • ISO-8859-13
    • ISO-8859-16
    • Windows-1250
    • IBM852
    • MAC-CENTRALEUROPE
  • Portuguese
    • ISO-8859-1
    • ISO-8859-9
    • ISO-8859-15
    • WINDOWS-1252
  • Romanian:
    • ISO-8859-2
    • ISO-8859-16
    • Windows-1250
    • IBM852
  • Russian
    • ISO-8859-5
    • KOI8-R
    • WINDOWS-1251
    • MAC-CYRILLIC
    • IBM866
    • IBM855
  • Slovak
    • Windows-1250
    • ISO-8859-2
    • IBM852
    • MAC-CENTRALEUROPE
  • Slovene
    • ISO-8859-2
    • ISO-8859-16
    • Windows-1250
    • IBM852
    • M

Example

import cchardet as chardet

with open(r"tests/samples/wikipediaJa_One_Thousand_and_One_Nights_SJIS.txt", "rb") as f:
    msg = f.read()
    result = chardet.detect(msg)
    print(result)

# Bound work for large inputs without copying msg[:200_000].
result = chardet.detect(msg, max_bytes=200_000)

# Inspect alternative encoding/language candidates ordered by confidence.
for candidate in chardet.detect_all(msg, max_bytes=200_000):
    print(candidate)

# Optionally downweight unlikely languages with ISO 639-1 codes. Values must
# be between 0 and 1; omitting this argument preserves the default ranking.
result = chardet.detect(msg, language_weights={"ru": 0.2, "uk": 0.2})

The CLI accepts the same opt-in weighting as repeatable arguments, for example cchardetect --language-weight ru=0.2 --language-weight uk=0.2 file.txt.

cChardet ships PEP 561 type information. The detect() and detect_all() results are typed as cchardet.ResultDict, and bytes, bytearray, and memoryview inputs are accepted by the type checker.

Benchmark

uv sync --locked
uv run python tests/bench.py

# Process-isolated statistical benchmark (optimized installed builds).
uv run python setup.py build_ext --inplace
uv run --no-sync python benchmarks/pyperf_compare.py \
  --corpus src/ext/uchardet/test --corpus tests/samples \
  --corpus ../charset_normalizer/data --rigorous -o benchmark.json

# Measure the sibling Pure Python fallbacks under the same harness.
uv run --no-sync python benchmarks/pyperf_compare.py \
  --pythonpath ../chardet/src --pythonpath ../charset_normalizer/src \
  --corpus src/ext/uchardet/test --rigorous -o benchmark-pure.json

# Compare regular and free-threaded CPython installations independently.
uv run --no-sync python benchmarks/pyperf_free_threading.py \
  --corpus src/ext/uchardet/test --rigorous -o free-threading.json

# Compare encoding and language accuracy on separately reported corpora.
uv run --no-sync python benchmarks/accuracy.py \
  --uchardet-corpus src/ext/uchardet/test \
  --chardet-corpus /path/to/chardet-test-data \
  --charset-normalizer-corpus /path/to/char-dataset

Results

See the detector and performance analysis for the methodology, current results, limitations, and optimization roadmap. External fixtures and detector-tuning changes follow the test data policy. Maintainer release steps are documented in the release process.

LICENSE

See COPYING file.

Contact

Support Platforms

  • Windows x86, x86_64, ARM64
  • Linux x86_64, aarch64
  • macOS x86_64, arm64

Wheel compatibility matrix

Platform CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython 3.15 CPython (additional flags: t) 3.14 CPython (additional flags: t) 3.15
macosx_10_13_x86_64
macosx_10_15_x86_64
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux_2_24_aarch64
manylinux_2_24_x86_64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
win32
win_amd64
win_arm64

Files in release

cchardet-2.4.0-cp311-cp311-macosx_10_9_x86_64.whl (184.1KiB)
cchardet-2.4.0-cp311-cp311-macosx_11_0_arm64.whl (187.1KiB)
cchardet-2.4.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (569.0KiB)
cchardet-2.4.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (570.2KiB)
cchardet-2.4.0-cp311-cp311-win32.whl (333.6KiB)
cchardet-2.4.0-cp311-cp311-win_amd64.whl (335.1KiB)
cchardet-2.4.0-cp311-cp311-win_arm64.whl (501.5KiB)
cchardet-2.4.0-cp312-cp312-macosx_10_13_x86_64.whl (185.1KiB)
cchardet-2.4.0-cp312-cp312-macosx_11_0_arm64.whl (188.2KiB)
cchardet-2.4.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (574.8KiB)
cchardet-2.4.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (578.7KiB)
cchardet-2.4.0-cp312-cp312-win32.whl (334.3KiB)
cchardet-2.4.0-cp312-cp312-win_amd64.whl (335.5KiB)
cchardet-2.4.0-cp312-cp312-win_arm64.whl (501.5KiB)
cchardet-2.4.0-cp313-cp313-macosx_10_13_x86_64.whl (184.5KiB)
cchardet-2.4.0-cp313-cp313-macosx_11_0_arm64.whl (187.3KiB)
cchardet-2.4.0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (570.9KiB)
cchardet-2.4.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (574.5KiB)
cchardet-2.4.0-cp313-cp313-win32.whl (334.0KiB)
cchardet-2.4.0-cp313-cp313-win_amd64.whl (335.1KiB)
cchardet-2.4.0-cp313-cp313-win_arm64.whl (501.2KiB)
cchardet-2.4.0-cp314-cp314-macosx_10_15_x86_64.whl (184.5KiB)
cchardet-2.4.0-cp314-cp314-macosx_11_0_arm64.whl (187.7KiB)
cchardet-2.4.0-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (571.1KiB)
cchardet-2.4.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (571.9KiB)
cchardet-2.4.0-cp314-cp314-win32.whl (339.7KiB)
cchardet-2.4.0-cp314-cp314-win_amd64.whl (342.0KiB)
cchardet-2.4.0-cp314-cp314-win_arm64.whl (513.0KiB)
cchardet-2.4.0-cp314-cp314t-macosx_10_15_x86_64.whl (187.7KiB)
cchardet-2.4.0-cp314-cp314t-macosx_11_0_arm64.whl (191.5KiB)
cchardet-2.4.0-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (638.7KiB)
cchardet-2.4.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (631.7KiB)
cchardet-2.4.0-cp314-cp314t-win32.whl (342.6KiB)
cchardet-2.4.0-cp314-cp314t-win_amd64.whl (345.4KiB)
cchardet-2.4.0-cp314-cp314t-win_arm64.whl (516.0KiB)
cchardet-2.4.0-cp315-cp315-macosx_10_15_x86_64.whl (184.5KiB)
cchardet-2.4.0-cp315-cp315-macosx_11_0_arm64.whl (187.5KiB)
cchardet-2.4.0-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (571.5KiB)
cchardet-2.4.0-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (572.5KiB)
cchardet-2.4.0-cp315-cp315-win32.whl (339.7KiB)
cchardet-2.4.0-cp315-cp315-win_amd64.whl (342.0KiB)
cchardet-2.4.0-cp315-cp315-win_arm64.whl (512.8KiB)
cchardet-2.4.0-cp315-cp315t-macosx_10_15_x86_64.whl (187.1KiB)
cchardet-2.4.0-cp315-cp315t-macosx_11_0_arm64.whl (191.0KiB)
cchardet-2.4.0-cp315-cp315t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (635.9KiB)
cchardet-2.4.0-cp315-cp315t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (629.9KiB)
cchardet-2.4.0-cp315-cp315t-win32.whl (342.4KiB)
cchardet-2.4.0-cp315-cp315t-win_amd64.whl (344.7KiB)
cchardet-2.4.0-cp315-cp315t-win_arm64.whl (515.5KiB)
cchardet-2.4.0.tar.gz (244.1KiB)
No dependencies