Jump to content



Photo

Chapter 14: Transliteration Using Php 5.3.8

iconv transliteration charset setlocale

  • Please log in to reply
2 replies to this topic

#1 MrRoboto

MrRoboto

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 2 December 2011 - 11:42 PM

Hello there everyone!

In chapter 14, i found the collation easy and simple to accomplish using the Collator object in PHP 5, but i haven't yet been able to accomplish transliterstion into different languages and character sets( Script 14.4 Trans.php ). I've tried to use iconv to get script 14.4 to work, but so far, it has failed me. And looking at the manual, the Transliterator object should be able to help me do this, but the documentation is vague and unsatisfactory at best. Has anyone else tackled transliteration in script 14.4 using PHP 5?
  • 0

#2 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,959 posts
  • LocationState College, PA (USA)

Posted 7 December 2011 - 7:17 PM

Sorry I haven't replied yet; been very busy. Let me see if I can't provide you with the exact code in a couple of days.
  • 0

#3 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,959 posts
  • LocationState College, PA (USA)

Posted 28 January 2012 - 11:25 AM

Terribly, terribly sorry for the delay on this. I've been wrapping up a book (way behind schedule) that I just finished two days ago. Then I had to install a custom version of PHP. The good news is that I was able to fix this, and the fix is easy. The bad news is that it requires PHP 5.4. Once you have PHP5.4, you only need to change the function call in trans.php:

echo "<p>$me is " . transliterator_transliterate ("Latin-$script", $me) . " in $script.</p>\n";
Originally the function call was:

echo "<p>$me is " . str_transliterate($me, 'Latin', $script) . " in $script.</p>\n";
I just tested it myself and it works fine. Let me know if you have any questions or problems. Apologies again for the delay!
  • 0





Also tagged with one or more of these keywords: iconv, transliteration, charset, setlocale