Everybody has a file where the database connection is established. They key is to add one more line to set the char encoding to utf8!
$database = mysql_connect($host, $user, $password);
mysql_select_db($db, $database);
mysql_set_charset('utf8', $database);
NOTE: don’t forget that your web page must contain the following meta tag:
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /
Sample code:
$str = "L'élèvevaà";
$s1 = utf8_encode($str);
$s2 = utf8_decode($s1);
echo $s1;
echo $s2;
No comments:
Post a Comment