Skip to content

Commit

Permalink
Revert "Revert "fix utf8 encoding""
Browse files Browse the repository at this point in the history
This reverts commit f8b56ce.
  • Loading branch information
hedii committed Jul 6, 2015
1 parent f8b56ce commit 08db893
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ColissimoApi/ColissimoApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ private function getPage($id)
private function storeTable($data)
{
$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>';
//$table = mb_convert_encoding($table, 'UTF-8', 'OLD-ENCODING');
$table = utf8_encode($table);
//var_dump($table); die;
$unique_id = uniqid();
$filePath = 'temp/' . $unique_id . '.html';
$file = file_put_contents('temp/' . $unique_id . '.html', $table);
$file = file_put_contents($filePath, $table);

// if $file is under 600, there is something wrong, stop everything
if ($file < 600) {
Expand All @@ -104,6 +107,8 @@ private function storeTable($data)
private function parse($filePath)
{
$content = file_get_contents($filePath);
//var_dump($content);
//die();
$dom = new DOMDocument();
@$html = $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'));
$dom->preserveWhiteSpace = false;
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
use ColissimoApi\ColissimoApi;

header('Content-Type: application/json');
header('Content-Type: application/json; charset=utf-8');
require 'ColissimoApi/ColissimoApi.php';
$colissimoApi = new ColissimoApi();
$colissimoApi->run();

0 comments on commit 08db893

Please sign in to comment.