Decoder is a C11 Unicode library plus a small set of text-processing tools built around it. The core library covers normalization, case mapping, text segmentation, character properties, script/security analysis, emoji helpers, and UTF conversion. The repository also includes CLI tools for PDF/EPUB text extraction, normalization, and OCR-assisted workflows.
This is a pre-1.0 release. The public API may change between minor versions until it stabilises. Specifically:
- Versioning —
0.xseries. Breaking changes are possible until1.0. - Platforms — tested on Linux and macOS (x86_64 and arm64). Windows and big-endian platforms are not yet supported.
- Thread safety — most read-only property lookups (e.g.
decoder_get_script, normalization, case folding) are safe for concurrent use afterdecoder_init(). Mutable engines such asdecoder_script_unification_tare not thread-safe; do not share an instance across threads without external synchronisation. - Memory ownership — pointers returned by
decoder_script_unification_get_scriptreference data owned by the engine and are invalidated by subsequentadd_rangecalls (which may realloc) and bycleanup. Copy the string if you need a longer lifetime. - Build flags —
-march=nativeis the default for development speed. For portable distribution builds, override viamake ARCH_FLAGS="-march=x86-64-v2 -mtune=generic"(or similar). - Unicode version — UCD 17.0.0. Updates require regenerating tables
via
make regenerate-lut. - Open punch list — see
TODO.mdfor completed work and known follow-ups (fuzz testing, Windows, additional locale tailorings, etc.).
Bug reports and API feedback welcome via GitHub issues.
- Unicode 17.0 data and conformance-focused algorithms
UAX #15normalization: NFC, NFD, NFKC, NFKDUAX #21case mapping and case folding, including full expansionsUAX #24/UAX #44script, block, and character property lookupUAX #29grapheme, word, and sentence segmentationUTS #39confusable, skeleton, and mixed-script checks- UTF-8 / UTF-16 / UTF-32 validation and conversion
The core library builds with the repository Makefile.
make -jMain outputs:
build/libunicode.a- public headers under
include/
The public umbrella header is decoder.h.
#include <decoder.h>
#include <stdio.h>
int main(void) {
decoder_init();
const uint32_t text[] = { 'A', 0x0308, 'B' };
size_t boundaries[8];
size_t count = 0;
if (decoder_find_grapheme_boundaries(text, 3, boundaries, 8, &count) == DECODER_SUCCESS) {
printf("grapheme boundaries: %zu\n", count);
}
decoder_cleanup();
return 0;
}For full API coverage, see API.md.
Recommended verification targets:
make test-public-api
make test-conformance-all
make test_simd_optimizationsStatic analysis helpers:
make inspect DIR=src/algorithms
make inspect-fixlist DIR=src/core SEVERITIES=error,warningBoundary performance notes live in docs/performance.md.
Useful benchmark targets:
make benchmark-boundaries
make benchmark-pdf
make bench-apiCLI tools live under tools/.
pdf_normalize: MuPDF-backed PDF/EPUB extraction plus Decoder cleanup and Markdown/text emissiontext_normalize: plain text normalizationpdf_ocr: Apple Vision OCR fallback for scanned PDFstools/decoder: wrapper script around the toolchain
Tool-specific usage notes are in tools/README.md.
include/: public headerssrc/algorithms/: Unicode algorithm implementationssrc/core/: public wrapper layersrc/api/: high-level API gluesrc/platform/: SIMD/platform supportgenerated/: generated Unicode tablestests/: public API, conformance, SIMD, and benchmark code
- The core library is intended to stay small and logic-focused; generated Unicode data lives in
generated/. - The PDF extraction tools have optional external dependencies.
pdf_normalizeuses MuPDF.pdf_ocruses Apple Vision on macOS.
MIT. See LICENSE.