Unicode.php 0.1.1 review
DownloadUnicode.php provides some PHP classes for maniuplating Unicode data
|
|
Unicode.php provides some PHP classes for maniuplating Unicode data. These classes are general purpose but are intended for use when working with Internationalised Domain Names (IDNs).
Existing support for Unicode and multi-byte strings in PHP is not great, requiring either an extension that is not compiled into PHP by default, or one of a number of third-party libraries, most of which are not currently maintained (for example, the I18N_UnicodeString class in PEAR was last updated in August 2004).
There is a Unicode extension under development, but it isn't public yet, and again requires a third party library to do the heavy lifting, so probably won't be enabled in a default PHP build.
Using the CentralNic Unicode Library is as simple as downloading the current release, and including the main Unicode.php file from your scripts. You then get instant access to the two Unicode_String and Unicode_Character classes.
Example Usage:
< ?php
require('Unicode.php');
$string =& new Unicode_String();
$string->fromUTF8("Ĥēĺļŏ, Ŵ?řļď!");
print "String contains ".$string->length()." characters.n";
print "String contains characters from the following blocks:".implode(', ', $string->blocks())."n";
print "String in UTF-8: ".$string->toUTF8()."n";
print "String in UPPERCASE: ".$string->toUpper()->toUTF8()."n";
$comma =& new Unicode_Character(ord(','));
$words = explode($comma);
foreach ($words as $word) {
print "Word has ".$word->length()." characters.n";
}
? >
What's New in This Release:
This release updates the block database to include a block that was missing in previous releases.
Full PhpDocumentor documentation has also been added.
Unicode.php 0.1.1 search tags