Skip to content

Commit

Permalink
fix UTF-8 encoding problems
Browse files Browse the repository at this point in the history
  • Loading branch information
hedii committed Jul 5, 2015
1 parent 1c95286 commit 1794f52
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ColissimoApi/ColissimoApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function getPage($id)
*/
private function storeTable($data)
{
$table = '<!DOCTYPE html><html><head><meta charset="utf-8"></head><body><table>' . $this->get_string_between($data, '<table class="dataArray" summary="Suivi de votre colis" width="100%">', '</table>') . '</table></body></html>';
$table = '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title></title></head><body><table>' . $this->get_string_between($data, '<table class="dataArray" summary="Suivi de votre colis" width="100%">', '</table>') . '</table></body></html>';
$unique_id = uniqid();
$filePath = 'temp/' . $unique_id . '.html';
$file = file_put_contents('temp/' . $unique_id . '.html', $table);
Expand All @@ -103,8 +103,9 @@ private function storeTable($data)
*/
private function parse($url)
{
$url = file_get_contents($url);
$dom = new DOMDocument();
$html = $dom->loadHTMLFile($url);
@$html = $dom->loadHTML(mb_convert_encoding($url, 'HTML-ENTITIES', 'UTF-8'));
$dom->preserveWhiteSpace = false;
$tables = $dom->getElementsByTagName('table');
$rows = $tables->item(0)->getElementsByTagName('tr');
Expand Down

0 comments on commit 1794f52

Please sign in to comment.