summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlarik <denis.kopitsa@gmail.com>2013-06-25 20:14:32 +0400
committerAlarik <denis.kopitsa@gmail.com>2013-06-25 20:14:32 +0400
commit128aa0e7c249421db33bea506f245f1f4f0a52d8 (patch)
tree7c61c6a75298404ff17e7ccc0f62bb22f2d17af4
parent01e72b1b144e408aaae119726cbb41c4ee1d86e0 (diff)
downloadyafpp-128aa0e7c249421db33bea506f245f1f4f0a52d8.tar.gz
yafpp-128aa0e7c249421db33bea506f245f1f4f0a52d8.zip
Encode fetched data to unicode based on config option "force_unicode"
-rw-r--r--init.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/init.php b/init.php
index e76a896..4d96d35 100644
--- a/init.php
+++ b/init.php
@@ -90,21 +90,30 @@ class Af_Feedmod extends Plugin implements IHandler
}
}
}
-
+
+ $charset = false;
if (!isset($config['force_charset'])) {
- $charset = false;
if ($content_type) {
preg_match('/charset=(\S+)/', $content_type, $matches);
if (isset($matches[1]) && !empty($matches[1])) $charset = $matches[1];
}
-
- if ($charset) {
- $html = '<?xml encoding="' . $charset . '">' . $html;
- }
} else {
// use forced charset
- $html = '<?xml encoding="' . $config['force_charset'] . '">' . $html;
+ $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;
}
+
+
+
+
@$doc->loadHTML($html);