I am using a DOMDocument to control / modify the HTML before it is displayed on the page. This is just an html snippet, not a full page. My initial problem was that the whole French character got messed up, and I was able to fix it after a trial error. Now, it seems, there is only one problem: is the character transforming ?.
The code:
<?php $dom = new DOMDocument('1.0','utf-8'); $dom->loadHTML(utf8_decode($row->text)); //Some pretty basic modification here, not even related to text //reinsert HTML, and make sure to remove DOCTYPE, html and body that get added auto. $row->text = utf8_encode(preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $dom->saveHTML()))); ?>
I know this is getting messy with utf8 decoding / encoding, but this is the only way to get it working so far. Here is an example line:
Entrance: Sans doute parce quil vient datteindre une date déterminante dans son spectaculaire cheminement
Exit: Sans doute parce qu? Il vient d? Atteindre une date d & eacute; terminante dans son spectacularire cheminement
If I find more details, I will add them. Thank you for your time and support!
php utf-8 domdocument
Kyrotomia
source share