I have a website that is translated in various languages including French. These pages aren't using Google Translate or any other third party script to do the translations. They have been manually translated.
So on the French's contact us page, I have a php contact form for visitors to fill in. There's french text on the contact us page and I have no problems with character encoding unlike the image below. When the form has been filled in successfully, an automatic message pops up BUT because the french language has special characters, those special characters in the success message have diamond shaped boxes with question marks in it:
MY CODE:
In the header of my contact page I have:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
In my PHP form which generates the success message (obviously javascript is used to display the message), I have (this is just a snippet of my entire php code however I think this part is what matters most):
$msg = wordwrap( $msg, 70 );
$headers = "From: $email\r\nBCC:{$bcc}\r\n" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/html; charset=utf-8" . PHP_EOL;
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n" . PHP_EOL;
if(mail($address, $e_subject, $msg, $headers)) {
echo "<div class='success'>";
echo "<h6>Nous vous remercions de votre demande.</h6>";
echo "<p><strong>NB:</strong> Si vous n'avez pas reçu une réponse dans 24 heures, veuillez vérifier votre <u style='font-weight:bold'>boîte spam</u>.</p>";
echo "<div class='close'> </div>";
echo "</div>";
} else {
echo 'ERROR!'; // Dont Edit.
}
Note in the code above:
$headers .= "Content-type: text/html; charset=utf-8" . PHP_EOL;
I suspect and assume that this is where my problem lies:
charset=utf-8
WHAT I'VE DONE IS:
1) I've tried changing my contact page's http-equiv="Content-Type" to
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
2) and in my php header:
$headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL;
These changes don't work and unfortunately my research on SO isn't getting me closer to a solution (considering everyone's situation is a little different than to perhaps mine). I'm not sure if this header is of any concern?:
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n" . PHP_EOL;
I appreciate your help and guidance.