javascript - PHP unicode char face convert to hex for Arabic -
i experiencing problem in converting arabic chars hex values
$text = "يي"; $text = mb_convert_encoding($text, "html-entities", "utf-8"); $text = preg_replace('~^(&([a-za-z0-9]);)~',htmlentities('${1}'),$text);
result :
يي
actually both chars ي in display changing faces according char position first, middle , end , want code //ﻳ == ي
'beginning' => 'ﻳ', 'middle' => 'ﻴ', 'end' => 'ﻲ', 'isolated' => 'ﻱ'
i need char values face on screen in html, javascript or in php.
to fix shaping imagettftext
, can use library ar-php:
require('../i18n/arabic.php'); $arabic = new i18n_arabic('glyphs'); $text = 'بسم الله الرحمن الرحيم'; $text = $arabic->utf8glyphs($text); imagettftext($im, 20, 0, 200, 100, $black, $font, $text);
full sample:
<?php // set content-type header("content-type: image/png"); // create image $im = @imagecreatefromgif('gd/bg.gif'); // create colors $black = imagecolorallocate($im, 0, 0, 0); $blue = imagecolorallocate($im, 0, 0, 255); // replace own font // full path , name $local = $_server['script_filename']; $pos = strrpos($script, '/'); $path = substr($script, 0, $pos); $font = $path.'/gd/ae_alhor.ttf'; // utf-8 charset $text = 'بسم الله الرحمن الرحيم'; imagettftext($im, 20, 0, 10, 50, $blue, $font, 'utf-8:'); imagettftext($im, 20, 0, 200, 50, $black, $font, $text); require('../i18n/arabic.php'); $arabic = new i18n_arabic('glyphs'); $text = 'بسم الله الرحمن الرحيم'; $text = $arabic->utf8glyphs($text); imagettftext($im, 20, 0, 10, 100, $blue, $font, 'arglyphs:'); imagettftext($im, 20, 0, 200, 100, $black, $font, $text); // using imagepng() results in clearer // text compared imagejpeg() imagepng($im); imagedestroy($im); ?>
Comments
Post a Comment