ruby-changes:8545
From: kou <ko1@a...>
Date: Fri, 31 Oct 2008 22:02:00 +0900 (JST)
Subject: [ruby-changes:8545] Ruby:r20079 (trunk): * lib/rss/converter.rb (RSS::Converter): use String#encode.
kou 2008-10-31 22:01:40 +0900 (Fri, 31 Oct 2008) New Revision: 20079 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20079 Log: * lib/rss/converter.rb (RSS::Converter): use String#encode. Modified files: trunk/ChangeLog trunk/lib/rss/converter.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20078) +++ ChangeLog (revision 20079) @@ -1,3 +1,7 @@ +Fri Oct 31 21:58:50 2008 Kouhei Sutou <kou@c...> + + * lib/rss/converter.rb (RSS::Converter): use String#encode. + Fri Oct 31 21:28:14 2008 Yusuke Endoh <mame@t...> * lib/webrick/httpauth/digestauth.rb Index: lib/rss/converter.rb =================================================================== --- lib/rss/converter.rb (revision 20078) +++ lib/rss/converter.rb (revision 20079) @@ -7,6 +7,10 @@ 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 @@ 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/