-2

Some of my contents which are coming directly from MySQL database are displayed like ’ , — characters.

I guess while inserting the data into the database, I mistakenly used SET NAMES utf-8 instead of SET NAMES utf8. For which the special characters are not converted properly and showing as it is.

In order to avoid these I used the follwoing in the page between <head> tag ..
<meta http-equiv="Content-Type" content="text/html";charset=UTF-8" /> .

But it didn't work.

How to convert these into its original characters while showing in the page ?

Kishore Patra
  • 215
  • 1
  • 3
  • 11

1 Answers1

0

Try this function

function charConversion($string, $to = "HTML-ENTITIES", $from = 'UTF-8,ASCII,ISO-8859-9,ISO-8859-1') {
    $str = mb_convert_encoding($string, $to, $from);
    $str = stripslashes($str);
    if (empty($str)) {
        return $string;
    }
    return $str;
}
Rax Shah
  • 531
  • 5
  • 18