Archives For transliterator

Transliteration in PHP 5.4

February 1, 2012

In the third edition of my “PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide” book, titled “[intlink id=”1582″ type=”page”]PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide[/intlink]”, I went out on a limb and used a beta version of PHP 6 when writing the book. PHP 6 was about half-way done at the time, and I didn’t want to complete the book, only to have it be outdated immediately thereafter (using PHP 6 wasn’t, by the way, an attempt to trick the reader into buying the book, as some cynical people have suggested). Well…[intlink id=”1067″ type=”post”]PHP 6 ended up dying due to many complications[/intlink] and I had the proverbial egg on my face (what one reader rightfully called my “Dewey Defeats Truman” moment). In truth, only about 5% of the book or so required PHP 6, so it wasn’t a devastating mistake, but I certainly felt foolish.

I had specifically wanted to discuss PHP 6 because of its intended support for Unicode, which is what the code in the book requires for a couple of examples. Even though PHP 6 was shelved, the key components have since been integrated into PHP 5.2, 5.3, and the forthcoming 5.4. Transliteration, the ability to convert text from one alphabet to another, was demonstrated in the book using the PHP 6 str_transliterate() function. That function went belly-up, and PHP 5.4 now has the Transliterator class instead. The documentation for the class in non-existent, but here’s what I figured out… Continue Reading…