Streamline Unicode strings and characters (code points) manipulations. Object oriented implementation.
Pull in the package through Composer.
composer require cybercog/php-unicode
$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)
$string = \Cog\Unicode\UnicodeString::of('Hello');
echo strval($string); // (string) "Hello"
$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('ÿ');
$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) "ÿ"
PHP Unicode
package is open-sourced software licensed under the MIT license by Anton Komarev.
CyberCog is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion.