unicode in php
Posted: Wed Jul 14, 2004 12:59 am
hi
i have a problem with unicode in PHP.
you know we can use preg_split function for converting a string to an array, so i need this function, but i can't use it with unicode strings.
my code is :
-----------------------
<html>
<head>
<meta http-equiv="Content-Language" content="fa">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
-------------------------
i can not use this function, because some unicode characters have two bytes. for example character "Le" in farsi.
when i use this code <? echo "<p> $t[1] </p>"; ?> i can not see "Le" character, becuase it have two bytes, but when i use <? echo "<p> $t[1]$t[2] </p>"; ?> i can see unicode character.
please help me, i do not know how can i solve this problem.
i have a problem with unicode in PHP.
you know we can use preg_split function for converting a string to an array, so i need this function, but i can't use it with unicode strings.
my code is :
-----------------------
<html>
<head>
<meta http-equiv="Content-Language" content="fa">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
Code: Select all
<?php
$str='لیست جدول ها'; //UTF8,language is farsi
$t=preg_split ( '//' , $str);
foreach ($t as $key => $value)
{
echo "<p> $value </p>";
}
?>i can not use this function, because some unicode characters have two bytes. for example character "Le" in farsi.
when i use this code <? echo "<p> $t[1] </p>"; ?> i can not see "Le" character, becuase it have two bytes, but when i use <? echo "<p> $t[1]$t[2] </p>"; ?> i can see unicode character.
please help me, i do not know how can i solve this problem.