How to convert characters into hindi characters in PHP

1.1k Views Asked by At

I am trying to convert database column that is stored in utf8_unicode_ci collation to hindi characters.

For example: दà¥à¤ƒà¤– का अधिकार- Quiz 1

This is not showing in hindi language, I even added <meta charset="utf-8"> after <head> tag. But still it displays the same.

In my previous website it was working fine, but when I imported data to my new website the characters are not being displayed as expected.

Then after some research, I found out some PHP functions as below

   echo iconv('UTF-8', 'ISO-8859-1', $utf8);
   echo "<br>";
   echo mb_convert_encoding($utf8, 'ISO-8859-1', 'UTF-8');
   echo "<br>";

iconv displayed Error iconv(): Detected an illegal character in input string and mb_convert_encoding outputs ?? ? ??- Quiz 1

The expected results for the above string is = दुःख का अधिकार- Quiz 1

ANSWER

After all the help I got the solution, I changed old database charset to UTF-8 using this

UPDATE quiz_question SET question_desc = CONVERT( CONVERT( CONVERT( question_desc USING latin1 ) USING BINARY ) USING UTF8 )

0

There are 0 best solutions below