Index: openacs-4/packages/feed-parser/tcl/feed-parser-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/feed-parser/tcl/feed-parser-procs.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/feed-parser/tcl/feed-parser-procs.tcl 30 May 2004 10:16:23 -0000 1.2 +++ openacs-4/packages/feed-parser/tcl/feed-parser-procs.tcl 30 May 2004 12:32:12 -0000 1.3 @@ -8,6 +8,22 @@ namespace eval feed_parser {} +ad_proc -public feed_parser::http_get_xml { + {-max_redirect 4} + -url:required + {-headers ""} +} { + Retrieves a document through HTTP GET in a way that's useful + for RSS feeds. Tries to preserve encoding. + + @author Guan Yang (guan@unicast.org) + @creation-date 2004-05-30 +} { + package require http + ::http::config -accept "text/xml, application/xml, application/rss+xml, application/atom+xml, application/rss, application/atom" -useragent "OpenACS" + set http [::http::geturl $url -headers $headers] +} + ad_proc -public feed_parser::sort_result { {-result:required} } { @@ -231,6 +247,18 @@ of that URL. @return A Tcl array-list data structure. } { + # Unless we have explicit encoding information, we'll assume UTF-8 + if { [regexp {^[[:space:]]*<\?xml[^>]+encoding="([^"]*)"} $xml match encoding] } { + set encoding [string tolower $encoding] + array set converts { + utf-8 utf-8 + iso-8859-1 iso8859-1 + } + if { [info exists converts($encoding)] } { + set xml [encoding convertfrom $converts($encoding) $xml] + } + } + # Prefill these slots for errors set result(channel) "" set result(items) ""