Overview
tc-lib-unicode-data is a data-centric package that ships Unicode lookup tables, mappings, and constants consumed by tc-lib-unicode and related libraries.
By separating large Unicode datasets from runtime algorithm code, the ecosystem can deliver deterministic, versioned Unicode data updates while keeping higher-level libraries lean.
Repository and API Docs
- GitHub: https://github.com/tecnickcom/tc-lib-unicode-data
- API docs: https://tcpdf.org/docs/srcdoc/tc-lib-unicode-data
- Packagist: https://packagist.org/packages/tecnickcom/tc-lib-unicode-data
Project Metadata
| Item | Value |
|---|---|
| Namespace | \Com\Tecnick\Unicode\Data |
| License | GNU LGPL v3 |
Installation
composer require tecnickcom/tc-lib-unicode-data
Where It Fits
Use indirectly through tc-lib-unicode or directly for low-level text inspection features.
Features
Data Coverage
- Unicode property and identity constants
- Script/category mapping data
- Bracket, mirroring, and shaping-related tables
Integration Role
- Runtime dependency for higher-level Unicode processing
- Pure data distribution with deterministic, versioned updates
Generated Unicode Data
Arabic, Bracket, Mirror, Pattern, and Type are generated from the Unicode Character Database. Version 3.0 regenerates them from UCD 17.0.0, reported by Type::UNICODE_VERSION.
| Class | UCD source | Content |
|---|---|---|
Type | extracted/DerivedBidiClass.txt | Bidi_Class of every code point (UAX #9) |
Pattern | extracted/DerivedBidiClass.txt | Regular expressions matching right-to-left and Arabic text |
Mirror | BidiMirroring.txt | Bidi_Mirroring_Glyph values used by rule L4 |
Bracket | BidiBrackets.txt | Paired brackets used by rule N0 |
Arabic | ArabicShaping.txt, UnicodeData.txt | Joining types, presentation forms, and ligatures |
Type::UNI lists only the code points whose Bidi_Class is not L; Type::getType() resolves any code point, including the blocks whose unassigned code points default to R, AL, or ET.
\Com\Tecnick\Unicode\Data\Type::getType(0x05D0); // 'R'
\Com\Tecnick\Unicode\Data\Type::getBidiClass(0x0660); // BidiClass::AN
\Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0628); // 'D'
To rebuild the tables from a newer UCD release:
make gendata UCDVERSION=17.0.0
make qa
Typed Enums
\Com\Tecnick\Unicode\Data\BidiClass is a backed enum of the bidirectional character classes (L, R, AL, EN, ES, ET, AN, CS, NSM, BN, B, S, WS, ON). The backing value is the canonical class abbreviation used in the UCD.
Upgrading from 2.x
Version 3.0 is a breaking release. The relevant API changes:
Type::UNIno longer contains the code points whose Bidi_Class isL. Read the class throughType::getType()instead ofType::UNI[$ord] ?? $fallback.Type::getBidiClass()returnsBidiClass::Lfor unlisted code points, andnullonly for the explicit formatting codes (LRE, LRO, RLE, RLO, PDF, LRI, RLI, FSI, PDI).Pattern::RTLandPattern::ARABICare code-point based (umodifier) and require a valid UTF-8 subject.Mirror::UNIfollowsBidiMirroring.txt: the quotation marks U+2018, U+2019, U+201C, U+201D, U+301D, and U+301E are no longer mirrored.Arabic::SUBSTITUTErows always hold the four[isolated, final, initial, medial]forms, repeating the isolated and final ones where a letter has no initial or medial form.Arabic::ENDis derived from the Joining_Type property and now lists every character that does not join to the following one.Arabic::JOININGandArabic::getJoiningType()expose the Joining_Type property.
Consumers should upgrade tc-lib-unicode to ^3.0 and tc-lib-pdf-font to ^3.13 at the same time; both read the bidi class through Type::getType().
Integration Notes
- Version this package in lockstep with components that consume its tables.
- Avoid ad-hoc table overrides unless downstream behavior is controlled.
- Run representative multilingual regression tests after updates.
Requirements
- PHP 8.2 or later
- Composer
Example
<?php
require_once __DIR__ . '/vendor/autoload.php';
echo md5(\Com\Tecnick\Unicode\Data\Identity::CIDHMAP);
Development and Packaging
- QA and local checks:
make deps,make help,make qa - Packaging:
make rpm,make deb
Support and Contribution
- Sponsor: https://github.com/sponsors/tecnickcom
- Contribution guide: https://github.com/tecnickcom/tc-lib-unicode-data/blob/main/CONTRIBUTING.md
- Security policy: https://github.com/tecnickcom/tc-lib-unicode-data/blob/main/SECURITY.md