Saturday, 31 December 2016

php - Question mark( �) displaying instead of each Bengali unicode character. How to fix it?



The problem is confusing,such as,




When I am trying to display a Bengali unicode word,'কলম' with this



 $data=$_POST['data'];
echo $data;


Then it displays the word 'কলম' properly as I wanted,



But when I split the word character by character with this




    for($i=0;$i<3;$i++)
{
echo $data[$i];
echo "+";
}


Then it display '�+�+�+' instead of displaying like this 'ক+ল+ম+'.




How to solve this problem .Thank you.



For information , I have declared charset utf-8 in head.




< meta http-equiv= " Content-Type " content= " text/html;
charset=utf-8 " />



Answer



Use mb_substr($data, $i, 1) instead. You are using a multi-byte string.



No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...