ruby-changes:8550
From: yugui <ko1@a...>
Date: Fri, 31 Oct 2008 22:56:56 +0900 (JST)
Subject: [ruby-changes:8550] Ruby:r20084 (ruby_1_9_1): merges r20079 from trunk into ruby_1_9_1.
yugui 2008-10-31 22:56:31 +0900 (Fri, 31 Oct 2008) New Revision: 20084 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20084 Log: merges r20079 from trunk into ruby_1_9_1. * lib/rss/converter.rb (RSS::Converter): use String#encode. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/lib/rss/converter.rb Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 20083) +++ ruby_1_9_1/ChangeLog (revision 20084) @@ -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 18:05:05 2008 Martin Duerst <duerst@i...> * enc/trans/single_byte.trans, maccroatioan-tbl.rb, Index: ruby_1_9_1/lib/rss/converter.rb =================================================================== --- ruby_1_9_1/lib/rss/converter.rb (revision 20083) +++ ruby_1_9_1/lib/rss/converter.rb (revision 20084) @@ -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/