cybercog / php-unicode
PHP Unicode library
Fund package maintenance!
paypal.me/antonkomarev
Installs: 4 438
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 2
Requires
- php: ^8.1
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2024-11-08 11:37:22 UTC
README
Introduction
Streamline Unicode strings and characters (code points) manipulations. Object oriented implementation.
Installation
Pull in the package through Composer.
composer require cybercog/php-unicode
Usage
Instantiate Unicode String
$string = \Cog\Unicode\UnicodeString::of('Hello');
UnicodeString
object will contain a list of Unicode characters.
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)
Represent Unicode String
$string = \Cog\Unicode\UnicodeString::of('Hello'); echo strval($string); // (string) "Hello"
Instantiate Unicode Character
$character = \Cog\Unicode\Character::of('ÿ'); $character = \Cog\Unicode\Character::ofDecimal(255); $character = \Cog\Unicode\Character::ofHexadecimal('U+00FF'); $character = \Cog\Unicode\Character::ofHtmlEntity('ÿ'); $character = \Cog\Unicode\Character::ofXmlEntity('ÿ');
Represent Unicode Character in any format
$character = \Cog\Unicode\Character::of('ÿ'); echo strval($character); // (string) "ÿ" echo $character->toDecimal(); // (int) 255 echo $character->toHexadecimal(); // (string) "U+00FF" echo $character->toHtmlEntity(); // (string) "ÿ" echo $character->toXmlEntity(); // (string) "ÿ"
License
PHP Unicode
package is open-sourced software licensed under the MIT license by Anton Komarev.
About CyberCog
CyberCog is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion.