Friday 3 August 2018

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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...