Download the PHP package cybercog/php-unicode without Composer
On this page you can find all versions of the php package cybercog/php-unicode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cybercog/php-unicode
More information about cybercog/php-unicode
Files in cybercog/php-unicode
Informations about the package php-unicode
PHP Unicode
Introduction
Streamline Unicode strings, code points and grapheme clusters manipulations. Object oriented implementation.
The library provides two levels of abstraction:
- Code point level (
CodePoint,UnicodeString) — works with individual Unicode code points. Requiresext-mbstring. - Grapheme level (
Grapheme,GraphemeString) — works with user-perceived characters (grapheme clusters). Requiresext-intl.
Requirements
| Class | Required Extensions |
|---|---|
CodePoint |
ext-mbstring |
UnicodeString |
ext-mbstring |
Grapheme |
ext-mbstring, ext-intl |
GraphemeString |
ext-mbstring, ext-intl |
PHP 8.1 or higher is required.
Installation
Pull in the package through Composer.
For grapheme cluster support, install the intl PHP extension.
Usage
Code Point
Represent Code Point in any format
Unicode String (code point level)
UnicodeString object will contain a list of code points.
For example, the Unicode string "Hello" is represented by the code points:
- U+0048 (H)
- U+0065 (e)
- U+006C (l)
- U+006C (l)
- U+006F (o)
Grapheme (grapheme cluster level)
Requires ext-intl.
Grapheme String (grapheme cluster level)
Requires ext-intl.
Real-world examples
Convert a character to all supported formats
Round-trip between entity formats
Inspect code points in a string
Code points vs. graphemes — why it matters
Detect combining marks
Why this library?
PHP provides mb_* and grapheme_* functions, but they are procedural and return raw strings. This library wraps them in immutable, type-safe value objects with two key benefits:
- Two levels of abstraction.
CodePoint/UnicodeStringwork with individual Unicode code points.Grapheme/GraphemeStringwork with user-perceived characters (grapheme clusters). Choose the right level for your use case instead of mixingmb_strlenandgrapheme_strlencalls. - Format conversion.
CodePointconverts between character, decimal, hexadecimal (U+XXXX), HTML entity, and XML entity formats in a single object. No need to chainmb_ord,dechex,htmlentitiesmanually.
License
PHP Unicodepackage is open-sourced software licensed under the Anton Komarev.
About CyberCog
CyberCog is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion.
All versions of php-unicode with dependencies
ext-mbstring Version *
