1
0

Add option to force convert linked page to unicode #15

Merged
dkopitsa merged 1 commits from master into master 2013-11-22 08:38:21 +00:00

View File

@ -91,20 +91,29 @@ class Af_Feedmod extends Plugin implements IHandler
}
}
if (!isset($config['force_charset'])) {
$charset = false;
if (!isset($config['force_charset'])) {
if ($content_type) {
preg_match('/charset=(\S+)/', $content_type, $matches);
if (isset($matches[1]) && !empty($matches[1])) $charset = $matches[1];
}
} else {
// use forced charset
$charset = $config['force_charset'];
}
if ($charset && isset($config['force_unicode']) && $config['force_unicode']) {
$html = iconv($charset, 'utf-8', $html);
$charset = 'utf-8';
}
if ($charset) {
$html = '<?xml encoding="' . $charset . '">' . $html;
}
} else {
// use forced charset
$html = '<?xml encoding="' . $config['force_charset'] . '">' . $html;
}
@$doc->loadHTML($html);