Unicode data tables, mappings and constants for PHP text processing.
💖 Part of the tc-lib-pdf / TCPDF ecosystem (100M+ installs). Sponsor its maintenance →
tc-lib-unicode-data provides the Unicode lookup tables, mappings and constants used by tc-lib-unicode and related libraries.
| Namespace | \Com\Tecnick\Unicode\Data |
| Author | Nicola Asuni info@tecnick.com |
| License | GNU LGPL v3 - see LICENSE |
| API docs | https://tcpdf.org/docs/srcdoc/tc-lib-unicode-data |
| Packagist | https://packagist.org/packages/tecnickcom/tc-lib-unicode-data |
| Class | Content |
|---|---|
Type |
Bidi_Class of every code point, with getType() and getBidiClass() |
BidiClass |
Backed enum of the strong, weak and neutral bidirectional classes |
Constant |
Code points of the bidirectional formatting characters and of some common separators |
Pattern |
Regular expressions matching right-to-left and Arabic text |
Mirror |
Mirrored form of the characters mirrored in a right-to-left context |
Bracket |
Paired brackets, by opening and by closing code point |
Arabic |
Joining types, presentation forms and ligatures, with getJoiningType() |
Encoding |
Character code to glyph name maps of 22 font encodings |
Latin |
Unicode to Latin1 character substitutions |
Identity |
CMap stream for the Identity-H encoding |
- PHP 8.2 or later
- Composer
composer require tecnickcom/tc-lib-unicode-data<?php
require_once __DIR__ . '/vendor/autoload.php';
echo \Com\Tecnick\Unicode\Data\Type::getType(0x05D0); // R
echo \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0628); // D
echo \Com\Tecnick\Unicode\Data\Encoding::MAP['cp1252'][128]; // EuroType::getBidiClass() returns the same class as a BidiClass enum case, and null for the explicit formatting codes (LRE, LRO, RLE, RLO, PDF, LRI, RLI, FSI, PDI).
Type, Pattern, Mirror, Bracket and Arabic are generated from the Unicode Character Database by tools/generate.php; Type::UNICODE_VERSION reports the version they derive from.
| Class | UCD source |
|---|---|
Type |
extracted/DerivedBidiClass.txt |
Pattern |
extracted/DerivedBidiClass.txt |
Mirror |
BidiMirroring.txt |
Bracket |
BidiBrackets.txt |
Arabic |
ArabicShaping.txt, UnicodeData.txt |
Type::UNI only lists 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.
To rebuild the tables from a UCD release:
make gendata UCDVERSION=17.0.0
make qamake deps
make help
make qamake rpm
make debFor system packages, bootstrap with:
require_once '/usr/share/php/Com/Tecnick/Unicode/Data/autoload.php';Contributions are welcome. Please review CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.