0

First yes I have read

HTML encoding issues - "Â" character showing up instead of " "

Let me explain my script

I have a cronjob that runs a php script using php-imap-client to retrieve emails from an inbox. At the top of this script I set header('Content-Type: text/html; charset=utf-8');

Even though I have set the encoding to UTF-8 I am still seeing that &nbsp is being encoded as Â

Eventually, the message body is inserted into MySQL and I can see the  record so I know it is happening before MySQL. I double checked and MySQL is set to UTF-8 as well.

I also set the message body when retrieved with $message = utf8_encode($message) and that did not work

Is it possible to set the encoding on a php script even though it is executed with a cronjob?

Here is how I am retrieving the body of the message with php-imap-client

$message = $email->message->html.PHP_EOL;
$doc->loadHTML($message);
$message = $doc->saveHtml();

I am just not sure at what point the encoding is screwing up.

Cesar Bielich
  • 4,754
  • 9
  • 39
  • 81

0 Answers0