diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-31 13:01:40 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-31 13:01:40 +0000 |
commit | ff5a076e7e1dbe8f255cb23a03be006fded7d277 (patch) | |
tree | 70ae8a364dc01ef47fe32c60509ecfdc921ef263 /lib | |
parent | b5a0eb6754acfaf6144109319afb88f3754ee70e (diff) | |
download | ruby-ff5a076e7e1dbe8f255cb23a03be006fded7d277.tar.gz |
* lib/rss/converter.rb (RSS::Converter): use String#encode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rss/converter.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/rss/converter.rb b/lib/rss/converter.rb index 415a319188..745d6de965 100644 --- a/lib/rss/converter.rb +++ b/lib/rss/converter.rb @@ -7,6 +7,10 @@ module RSS include Utils def initialize(to_enc, from_enc=nil) + if "".respond_to?(:encode) + @to_encoding = to_enc + return + end normalized_to_enc = to_enc.downcase.gsub(/-/, '_') from_enc ||= 'utf-8' normalized_from_enc = from_enc.downcase.gsub(/-/, '_') @@ -23,7 +27,11 @@ module RSS end def convert(value) - value + if value.is_a?(String) and value.respond_to?(:encode) + value.encode(@to_encoding) + else + value + end end def def_convert(depth=0) |