I retrieve some text from my MySQL database and then I pass it through tidy like so:
$config = array(
'wrap' => 0,
'lower-literals' => 1,
'preserve-entities' => 1,
'drop-empty-paras' => 0,
'indent' => 1,
'new-blocklevel-tags' => 'unsubscribe, webversion'
);
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
$fp = fopen($file_name, 'wb');
fwrite($fp, $tidy->value);
fclose($fp);
The contents then gets saved. However, when I view the text file there is some character encoding issues. In the database there is a sring that looks like this Stan’s. However, when I view that same string in the text file it looks like this Stan’s.
The field in the database and the database itself have a charset of utf8_general_ci.
What am I missing?
try:
alternatively, you may try:
Also try not setting the character encoding by changing your code to: