Skip to main content

CodecCat

Fast character-encoding detection for Python, backed by native inference and strict decoding.

Release PyPI Python License

import codeccat

data = "こんにちは".encode("shift_jis")

result = codeccat.detect(data)

print(result.encoding)
print(result.text)

CodecCat detects the character encoding of byte input and decodes it to Unicode.

It is designed for applications that need predictable decoding behavior, low detection latency, and explicit handling of ambiguous input.

Why CodecCat?

  • Strict decoding — invalid text is not silently replaced.
  • Native inference — the default detector does not require NumPy or scikit-learn.
  • Explicit ambiguity — callers can inspect result.ambiguous instead of assuming every detection is certain.
  • Portable wheels — published for Linux, macOS, and Windows on supported x86-64 and ARM64 targets.
  • Stable public API — the 0.1.x line has a documented compatibility contract.

Encoding detection is inherently probabilistic: some byte sequences can validly represent more than one encoding. CodecCat exposes that uncertainty rather than treating every result as uniquely identifiable.

Install

Install the latest Stable release from PyPI:

python -m pip install codeccat

To pin the currently published first Stable release (before v0.1.1 publication):

python -m pip install codeccat==0.1.0

CodecCat ships binary Wheels for Python 3.10–3.14 on supported Linux (glibc 2.28+, x86-64/ARM64), macOS (Intel/Apple Silicon) and Windows (x86-64/ARM64). The first PyPI release has no sdist, so unsupported platforms cannot fall back to building it from source. Future Stable releases now have a source-distribution round-trip CI (source archive → native Wheel → clean install, Python 3.10–3.14) and a reviewed manual GitHub Release / PyPI OIDC publication pipeline. This future release pipeline has passed its dry-run; it does not retroactively add an sdist to v0.1.0.

For offline installs and artifact SHA256 checks, use GitHub Stable v0.1.0.

Usage

Detect and decode

import codeccat

data = "こんにちは".encode("shift_jis")
result = codeccat.detect(data)

print(result.encoding)
print(result.text)
print(result.ambiguous)

Decode directly

If you only need the decoded text:

text = codeccat.decode(data)

Command line

Inspect a file:

codeccat file.txt

Decode it:

codeccat --decode file.txt > readable.txt

Performance

CodecCat v0.1.0 was compared with chardet and charset-normalizer using the same 843 text samples across five fixed test sets on Ubuntu 24.04 / Python 3.12.

Metric CodecCat chardet charset-normalizer
Correctly decoded text 97.98% 98.34% 82.80%
Exact encoding name 93.36% 84.46% 69.16%
Total CPU time 779 ms 1,008 ms 1,205 ms
Typical latency (p50 range) 0.94–1.04 ms 0.49–0.83 ms 0.85–1.16 ms
Slower-case latency (p95 range) 1.38–1.65 ms 3.23–3.86 ms 3.55–5.15 ms
Peak RAM 66–69 MiB 61–64 MiB 40–44 MiB

CodecCat is not uniformly better on every metric.

In this benchmark, chardet correctly decoded 3 more samples, while CodecCat identified the exact encoding more often, used less total measured CPU time, and showed substantially lower p95 latency. CodecCat used more peak memory.

These measurements were collected on a shared CI runner. Small timing differences should not be interpreted as statistical guarantees.

Independent-source confirmation (published Stable 0.1.0)

An additional pinned external-source benchmark tested the published Stable Wheel, not a development build. It screened every eligible byte input against the historical training corpus before scoring (no raw-byte/prefix/sampled-block overlap indicators triggered). Ground truth was strict Unicode text, and all three detectors received the same input bytes.

External source CodecCat chardet 7.7.0 charset-normalizer 3.5.2
GNOME Nautilus UTF-8 PO (124 original files) 122/124 (98.39%) 124/124 (100%) 124/124 (100%)
CPython CJK fixture pairs (30 original files) 26/30 (86.67%) 29/30 (96.67%) 25/30 (83.33%)

Nautilus is a new external source for this evaluation. CPython is a previously examined, preregistered confirmation source, not a newly blind sample. The Nautilus group is UTF-8-only, and the CPython set is small and CJK-focused. Neither source represents the real-world mix of encodings; do not pool the groups into a claimed production accuracy rate. A negative raw-byte overlap screen is not proof of semantic independence.

Historical development benchmark limitation

The 843-sample benchmark above includes 633 samples from the model's training source, plus previously examined development texts. Its 97.98% figure is therefore an engineering regression benchmark, not an independent estimate of real-world accuracy. The external-source findings also show that CodecCat can underperform chardet on unseen source families.

A source-level paired GNOME Software test showed 18 additional correct decodes with the same frozen model without observed regressions in that test set.

See full benchmark methodology and limitations and the frozen external-source protocol.

Optional ambiguity diagnostic (included in v0.1.1 release candidate)

The repository contains an opt-in, non-mutating C1-control ambiguity diagnostic after PR #47. It is included in the v0.1.1 release candidate, but not in the published codeccat==0.1.0 Wheel. Do not assume PyPI has v0.1.1 until its release has been verified. This diagnostic is not a model-accuracy upgrade.

On a v0.1.1 Wheel containing this feature:

from codeccat import detect
from codeccat.diagnostics import inspect_ambiguity

raw = b"Price: \x80; total."
result = detect(raw)
diagnostic = inspect_ambiguity(raw, result)

if diagnostic.warning:
    print(diagnostic.reason, diagnostic.alternative_encodings)
    # Check a trusted source encoding before choosing another interpretation.

The function inspects only already returned model candidates when selected text contains C1 controls (U+0080–U+009F) and an alternative strictly decodes those bytes without C1 controls. It does not change result.encoding, result.text, result.candidates, result.ambiguous, BOM handling, or L3 behavior. A warning does not prove the current decoding is wrong. Some legal ISO-8859-1 text intentionally contains these controls, and lack of a warning does not prove correctness.

A fixed historical HTML study screened 2,675 files and evaluated 1,886 eligible files after deduplication, strict label decoding, and historical training-source overlap checks. The warning flagged 17 of 572 label-disagreeing results and none of 1,314 label-agreeing results. Archive labels are not independently verified ground truth, so these numbers are not a real-world sensitivity or false-positive rate. See the validation record and protocol.

Detection semantics

Character encoding is not always uniquely identifiable from bytes alone.

For applications where the exact encoding matters:

result = codeccat.detect(data)

if result.ambiguous:
    # Apply application-specific handling.
    ...

CodecCat uses strict decoding behavior. Invalid byte sequences are not silently converted using replacement characters.

Encoding inference remains probabilistic and cannot guarantee a uniquely correct answer for arbitrary input.

Stability

CodecCat v0.1.0 is the first stable release.

The 0.1.x line preserves the documented public API, including the primary detection and decoding calls and documented result fields.

See the public API compatibility contract.

Distribution and provenance

Published wheels are built for supported Linux, macOS, and Windows targets. The frozen default model is distributed with the package and verified as part of the release process.

Model and source provenance, including third-party rights considerations, are documented separately.

See Rights and Provenance.

Train your own model (independent PyPI package)

codeccat-train 0.1.0 is independently published on PyPI (Trainer release CI). It is not included in the default pip install codeccat and is not required for production inference. The runtime stays dependency-light; training uses NumPy and scikit-learn in its own environment.

From a repository checkout, with your own labeled byte files and a grouped JSONL manifest:

python -m venv .trainer-env
.trainer-env/bin/python -m pip install codeccat-train==0.1.0
.trainer-env/bin/python -m codeccat_train fit \\
  --manifest my-data/manifest.jsonl \\
  --output custom.ccm \\
  --report training-report.json

Then load the model using an independent environment containing the published Runtime:

from codeccat import CodecCat
custom_detector = CodecCat.from_files("custom.ccm")
result = custom_detector.detect("café".encode("utf-8"))
print(result.encoding, result.text)

The Trainer also supports --precision f32 (compact CCM2), evaluate (candidate-vs-unchanged Stable with paired improvements/regressions on labeled bytes), and optional fit-l3 (separately trained language artifact, disabled by default). The common training engine can be used with your private dataset or a separately approved official dataset; supplying your data does not grant the project rights to it.

Verified: separate training/Runtime environments, deterministic training, safe manifest checks, native custom-model loading, Linux x64/ARM64 and macOS/Windows checks, and exact historical official L2/L3 artifact reconstruction under pinned sources and dependencies. Not established: universal legal clearance for historical datasets, or improved real-world accuracy of a new model. Custom models do not automatically replace the shipped default model.

See quick start, Trainer README, model contribution rules, rights/provenance and roadmap.

Contributing and maintenance

CodecCat is maintained in public. Contributions are welcome, including concise bug reports, documentation, tests, native packaging fixes, source-aware accuracy studies and reproducible performance work.

You can submit small documentation fixes directly as PRs. Discuss larger API, model, dependency or release changes in an Issue before implementation. CI covers supported platforms; contributors are not expected to reproduce the entire six-platform matrix locally.

PyPI · GitHub Releases · Release notes · Issues · Roadmap · Benchmarks · Stability · License

Metadata

Release files for codeccat 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codeccat 0.1.1
File Size Uploaded Provenance Actions
codeccat-0.1.1.tar.gz 7.4 MB With provenance Details for codeccat-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for codeccat 0.1.1
File Actions
codeccat-0.1.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for codeccat-0.1.1-cp310-abi3-win_arm64.whl
codeccat-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for codeccat-0.1.1-cp310-abi3-win_amd64.whl
codeccat-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for codeccat-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
codeccat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for codeccat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
codeccat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for codeccat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
codeccat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for codeccat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 53.1 MB

Release files / codeccat-0.1.1.tar.gz

Download URL codeccat-0.1.1.tar.gz
Size 7.4 MB
Tags Source
SHA-256 checksum
How to use checksums
07d48cb70bfaf49ce6d455022a4fb7eded22159fed6c6cdfea912533c2646596
BLAKE2b-256 checksum
How to use checksums
e7f48a0538bd3725c54024d88f4c9d9cc4cdfad3d1e5ef96ba6d428a213e3334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / codeccat-0.1.1-cp310-abi3-win_arm64.whl

Download URL codeccat-0.1.1-cp310-abi3-win_arm64.whl
Size 7.5 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
a4b7ee26685b4ca7273858a2430419e8d69fc039e84e56fc05cc0e0b87662b30
BLAKE2b-256 checksum
How to use checksums
48b525f2ece54167af524699d903f4821eee48b9d4bb0367de2182c82ab4d7fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / codeccat-0.1.1-cp310-abi3-win_amd64.whl

Download URL codeccat-0.1.1-cp310-abi3-win_amd64.whl
Size 7.6 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
67dbc8309d047b82ebfb9cc5b5d379ca77c4fc962551e2cd1c1eb1beda157bda
BLAKE2b-256 checksum
How to use checksums
05b35e4dad915466fafae960489579a68ca4782424f6913e12aec67a7d7e74d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / codeccat-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL codeccat-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
Size 7.6 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
72881a9ba5cac8de104d2b9650f2200daae44dff6d90f9d0affaed70e98b57fe
BLAKE2b-256 checksum
How to use checksums
2d9d088f2af0072b22d99f8ae4a3685819a99472a47ad8593f6f76b4d5f06573
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / codeccat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL codeccat-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
Size 7.6 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
96995c4222d6ba597a00ee268dc1c56a6b7d83e72d93fdb953b452ffe6ab4d94
BLAKE2b-256 checksum
How to use checksums
ace827a707beb4e6f7bf605a346fbf37e71307dff8c0e09f9ca4e174317cf014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / codeccat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL codeccat-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 7.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b36d000f8312964322b2153ad56184277bd9e01097cc3c0f072dc7a4b7a8d5dd
BLAKE2b-256 checksum
How to use checksums
3779dcfa6a099b388e55dbb3c3d95831d7f3e84982eca7e0b107514e33107f7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / codeccat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL codeccat-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 7.7 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1835d05f6b0e009ea6cff06443025b914c9eab46d01468b0973543b00ded2e39
BLAKE2b-256 checksum
How to use checksums
27e05b78c570756cc1d5c923cf2fda407c21d9d6f487b06af9e1a5be3f3744f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for codeccat 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for codeccat-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

7 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page