Skip to content
Advertisement

How to Convert Arabic Characters to Unicode Using PHP

I want to to know how can I convert a word into unicode exactly like: http://www.arabunic.free.fr/

can anyone know how to do that using PHP considering that Arabic text may contains ligatures?

thanks

Edit

I’m not sure what is that “unicode” but I need to have the Arabic Character in it’s equivalent machine number considering that arabic characters have different contextual forms depending on their position – see here:

http://en.wikipedia.org/wiki/Arabic_alphabet#Table_of_basic_letters

the same character in different position:

ب‎ | ـب‎ | ـبـ‎ | بـ‎

I think it must be a way to convert each Arabic character into it’s equivalent number, but how?

Edit

I still believe there’s a way to convert each character to it’s form depending on positions

any idea is appreciated..

Advertisement

Answer

All what you need is function called: utf8Glyphs which you can find it in ArGlyphs.class.php download it from ar-php and visit Ar-PHP for the ArPHP more information about the project and classes.

This will reverse the word with same of its characters (glyphs).

Example of usage:

    <?php
    include('Arabic.php');
    $Arabic = new Arabic('ArGlyphs');

    $text = 'بسم الله الرحمن الرحيم';
    $text = $Arabic->utf8Glyphs($text);
    echo $text;
    ?>
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement