Add encoding convert

This commit is contained in:
Michael RICOIS 2012-09-03 09:42:58 +00:00
parent 86b601eb37
commit 0cc6b90e8b

View File

@ -57,6 +57,16 @@ if(count($opts->getOptions())==0 || isset($opts->help))
exit;
}
function getPageHeader($start,$end,$header)
{
$pattern = '/'. $start .'(.*?)'. $end .'/';
if (preg_match($pattern, $header, $result)) {
return $result[1];
} else {
return false;
}
}
function getPage($url, $curl_data = '', $verbose=false)
{
global $ckfile;
@ -103,6 +113,10 @@ function getPage($url, $curl_data = '', $verbose=false)
$header = curl_getinfo($ch);
curl_close($ch);
//Rewrite encoding to UTF-8
$encoding = getPageHeader('Content-Type: text/html; charset=', '\n', $header);
$content = iconv($encoding, 'UTF-8', $content);
// $header['errno'] = $err;
// $header['errmsg'] = $errmsg;
// $header['content'] = $content;