]> git.wh0rd.org - tt-rss.git/commitdiff
rework magpie encoding fix patch
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 13 Aug 2007 06:08:55 +0000 (07:08 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 13 Aug 2007 06:08:55 +0000 (07:08 +0100)
magpierss/rss_parse.inc

index 8a67523b50ee5710f9f12b54e22073cd437857c2..0dfa5c7fb0542c89f69f25e2c458d0e35a9515c1 100644 (file)
@@ -141,11 +141,18 @@ class MagpieRSS {
 
                                        xml_parser_free( $this->parser );
 
+                                       if (preg_match('/<\?xml.*?encoding="([^ ]+)".*?\?>/',
+                                                               $source, $matches)) {
+
+                                               $enc = $matches[1];
+                                       } else {
+                                               $enc = mb_detect_encoding($string);
+                                       }
+
                                        list($parser, $source) = $this->create_parser($source, 
                        $output_encoding, $input_encoding, $detect_encoding);
 
-                                       $source = mb_convert_encoding($source, "UTF-8",
-                                                mb_detect_encoding($source));
+                                       $source = mb_convert_encoding($source, "UTF-8", $enc);
 
                              $this->parser = $parser;