カテゴリ | |
---|---|
サマリ | #showrss の不具合?? |
バージョン | 1.4.6 |
投稿者 | matsuo2 |
状態 | 完了 |
投稿日 | 2006-04-06 (木) 01:19:31 |
天気予報を表示しようとしたのですが
◆天気 愛知 西部(名古屋)
#showrss(http://weather.goo.ne.jp/area/5110.rdf,0,1) ↑表示されない。(06/04/06)
◆天気 愛知 東部(豊橋)
#showrss(http://weather.goo.ne.jp/area/5120.rdf,0,1) ↑こちらはうまく表示される。
他のrssリーダではうまく表示されていたので#showrssに原因があるのではないかと・・・
--- showrss.inc.php.org +++ showrss.inc.php @@ -52,9 +51,13 @@ if (! class_exists($class)) $class = 'ShowRSS_html'; list($rss, $time) = plugin_showrss_get_rss($rssurl, $usecache); + if ($rss === FALSE) return '<p>showrss: cannot get rss from server.</p>' . "\n"; + if (is_string($rss)) + return "<p>showrss: error ${rss}\n"; + $obj = new $class($rss); $timestamp = ''; @@ -210,12 +213,20 @@ $this->is_item = FALSE; $this->tag = ''; - // Detect encoding - $this->encoding = mb_detect_encoding($buf); + /* Detect encoding ex. <?xml version="1.0" encoding="EUC-JP" ?> */ + $lines = split(">", $buf, 1); + if (preg_match( "/encoding=\"(.+)\"/i", $lines[0], $encoding)) { + $this->encoding = $encoding[1]; + } else { + $this->encoding = mb_detect_encoding($buf); + } + + // Convert to utf-8 if (! in_array(strtolower($this->encoding), array('us-ascii', 'iso-8859-1', 'utf-8'))) { $buf = mb_convert_encoding($buf, 'utf-8', $this->encoding); $this->encoding = 'utf-8'; } + $xml_parser = xml_parser_create($this->encoding); xml_set_element_handler($xml_parser, array(& $this, 'start_element'), array(& $this, 'end_element')); xml_set_character_data_handler($xml_parser, array(& $this, 'character_data'));