I browsed several questions regarding this topic here already, however, without a solution. I am loading data into a DomDocument-Object. Once printing the results of a Xpath-query it prints a � instead of a ñ.
My controller includes:
public function index() {
$data = array();
$dom = new DomDocument();
@$dom->loadHTML(mb_convert_encoding(file_get_contents('http://www.example.com'), 'HTML-ENTITIES', 'UTF-8'));
$xpath = new DomXpath($dom);
foreach($xpath->query('//span') as $element) {
$data['titles'[] = $element->nodeValue;
}
$this->load->view('view_example', $data);
}
My view_example.php includes:
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
My view_example.php also includes:
<?php
foreach($titles as $element) {
echo $element;
}
?>
My config file includes:
$config['charset'] = 'UTF-8';
Also, I re-checked the character-encoding of every file using Komodo Edit and NotePad++. I picked UTF-8 without BOM for every file.
When removing the @ sign it prints the following warning, is it relevant to this case?:
DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: X