tc-lib-unicode-data

Technical overview and integration notes for tc-lib-unicode-data

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

Project Metadata

ItemValue
Namespace\Com\Tecnick\Unicode\Data
LicenseGNU 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.

ClassUCD sourceContent
Typeextracted/DerivedBidiClass.txtBidi_Class of every code point (UAX #9)
Patternextracted/DerivedBidiClass.txtRegular expressions matching right-to-left and Arabic text
MirrorBidiMirroring.txtBidi_Mirroring_Glyph values used by rule L4
BracketBidiBrackets.txtPaired brackets used by rule N0
ArabicArabicShaping.txt, UnicodeData.txtJoining 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::UNI no longer contains the code points whose Bidi_Class is L. Read the class through Type::getType() instead of Type::UNI[$ord] ?? $fallback.
  • Type::getBidiClass() returns BidiClass::L for unlisted code points, and null only for the explicit formatting codes (LRE, LRO, RLE, RLO, PDF, LRI, RLI, FSI, PDI).
  • Pattern::RTL and Pattern::ARABIC are code-point based (u modifier) and require a valid UTF-8 subject.
  • Mirror::UNI follows BidiMirroring.txt: the quotation marks U+2018, U+2019, U+201C, U+201D, U+301D, and U+301E are no longer mirrored.
  • Arabic::SUBSTITUTE rows 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::END is derived from the Joining_Type property and now lists every character that does not join to the following one.
  • Arabic::JOINING and Arabic::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

 

© 2004-2026 – Nicola Asuni - Tecnick.com - All rights reserved.
sponsor - legal notice - privacy