Problem with PHP and Mysql UTF-8 (Special Character)

Take a look at utf8_encode() and utf8_decode(). Also take a look at multibyte string functions.


Probably what is happening is that the default character set for the client is not set to UTF-8, so you're getting tranposition in one direction or the other. This is covered in a number of different ways here:

Often an initialization query of "SET NAMES utf8" just after the connection is instantiated will solve the issue going forward but make sure that what you think is stored (utf8) is actually what was stored. You might have a cleanup job if not.


Try seting the client encoding before using the DB.

mysql_query("SET NAMES 'utf8'");

If the above doesn't work use the utf8 encode/decode functions:

<?
$string ="Étuit";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<?
echo $string; // echo's '?tuit'
echo utf8_encode($string); // echo's 'Étuit'
?>