Permalink
Browse files

Merge pull request #2 from Johannes13/master

feedencoding
  • Loading branch information...
2 parents b8d95b7 + 53f3705 commit 8c1aa3d644cb17a8aeaf11b60b03ca55c971d7a1 @hm2k hm2k committed Aug 17, 2012
Showing with 24 additions and 4 deletions.
  1. +3 −0 HISTORY
  2. +4 −0 README
  3. +3 −0 TODO
  4. +14 −4 rss-synd.tcl
View
@@ -2,6 +2,9 @@
HISTORY
################################################################################
+0.6 (2012-02-27)
+* Added support for feedencoding to read feeds with any encoding.
+
0.5 (2011-01-05)
* HM2K joined the project
* Split license from rss-synd.tcl into LICENSE file
View
4 README
@@ -124,6 +124,10 @@ charset This is the charset you want the feed to be outputted using.
Example: utf-8
cp1251
iso8859-1
+feedencoding This is the charset the feed is in. (look in the sourcecode
+ it is usualy mentioned in the <?xml> header. Please note that
+ Tcl uses other encoding names, esp. the Windows-xxx encodings.
+ In Tcl they are named cpxxx.
Cookies:
View
3 TODO
@@ -11,4 +11,7 @@
formatted and is looping the timer. Test with html4 pages. The parser
could also be improved to handle this.
+
+0.? - Auto select the encoding based on the xml header. If the xml header can't be read, try again with utf-16.
+ This requires a map of the xml encoding names and tcl encodings
EOF
View
@@ -1,4 +1,4 @@
-# rss-synd.tcl -- 0.5
+# rss-synd.tcl -- 0.5.1
#
# Highly configurable asynchronous RSS & Atom feed reader for Eggdrops
# written in TCL. Supports multiple feeds, gzip compressed feeds,
@@ -34,8 +34,8 @@ proc ::rss-synd::init {args} {
variable version
variable packages
- set version(number) 0.5
- set version(date) "2011-01-05"
+ set version(number) 0.5.1
+ set version(date) "2012-02-27"
package require http
set packages(base64) [catch {package require base64}]; # http auth
@@ -99,7 +99,13 @@ proc ::rss-synd::init {args} {
set tmp(trigger-type) [split $tmp(trigger-type) ":"]
if {([info exists tmp(charset)]) && ([lsearch -exact [encoding names] [string tolower $tmp(charset)]] < 0)} {
- putlog "\002RSS Error\002: Unable to load feed \"$feed\", unknown encoding \"$tmp(encoding)\"."
+ putlog "\002RSS Error\002: Unable to load feed \"$feed\", unknown encoding \"$tmp(charset)\"."
+ unset rss($feed)
+ continue
+ }
+
+ if {([info exists tmp(feedencoding)]) && ([lsearch -exact [encoding names] [string tolower $tmp(feedencoding)]] < 0)} {
+ putlog "\002RSS Error\002: Unable to load feed \"$feed\", unknown feedencoding \"$tmp(feedencoding)\"."
unset rss($feed)
continue
}
@@ -311,6 +317,10 @@ proc ::rss-synd::feed_callback {feedlist args} {
}
set data [::http::data $token]
+
+ if {[info exists feed(feedencoding)]} {
+ set data [encoding convertfrom [string tolower $feed(feedencoding)] $data]
+ }
if {[info exists feed(charset)]} {
if {[string tolower $feed(charset)]) == "utf-8" && [is_utf8_patched]} {

0 comments on commit 8c1aa3d

Please sign in to comment.