ruby-changes:18091
From: naruse <ko1@a...>
Date: Tue, 7 Dec 2010 20:47:50 +0900 (JST)
Subject: [ruby-changes:18091] Ruby:r30112 (trunk): * ext/nkf/lib/kconv.rb (String#kconv): fix typo and update rdoc.
naruse 2010-12-07 20:47:39 +0900 (Tue, 07 Dec 2010) New Revision: 30112 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30112 Log: * ext/nkf/lib/kconv.rb (String#kconv): fix typo and update rdoc. patched by Kouhei Yanagita [ruby-dev:42696] Modified files: trunk/ChangeLog trunk/ext/nkf/lib/kconv.rb trunk/test/nkf/test_kconv.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30111) +++ ChangeLog (revision 30112) @@ -1,3 +1,8 @@ +Tue Dec 7 18:56:52 2010 NARUSE, Yui <naruse@r...> + + * ext/nkf/lib/kconv.rb (String#kconv): fix typo and update rdoc. + patched by Kouhei Yanagita [ruby-dev:42696] + Tue Dec 7 20:32:11 2010 Kouhei Sutou <kou@c...> * test/rexml/test_doctype.rb: add Accessor to test case name. Index: ext/nkf/lib/kconv.rb =================================================================== --- ext/nkf/lib/kconv.rb (revision 30111) +++ ext/nkf/lib/kconv.rb (revision 30112) @@ -51,8 +51,8 @@ # call-seq: # Kconv.kconv(str, to_enc, from_enc=nil) # - # Convert <code>str</code> to out_code. - # <code>out_code</code> and <code>in_code</code> are given as constants of Kconv. + # Convert <code>str</code> to <code>to_enc</code>. + # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects. def kconv(str, to_enc, from_enc=nil) opt = '' opt += ' --ic=' + from_enc.to_s if from_enc @@ -199,10 +199,10 @@ # call-seq: # String#kconv(to_enc, from_enc) # - # Convert <code>self</code> to out_code. - # <code>out_code</code> and <code>in_code</code> are given as constants of Kconv. + # Convert <code>self</code> to <code>to_enc</code>. + # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects. def kconv(to_enc, from_enc=nil) - form_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0] + from_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0] Kconv::kconv(self, to_enc, from_enc) end Index: test/nkf/test_kconv.rb =================================================================== --- test/nkf/test_kconv.rb (revision 30111) +++ test/nkf/test_kconv.rb (revision 30112) @@ -71,4 +71,11 @@ assert_equal(@jis_str, @utf8_str.kconv(::NKF::JIS)) assert_equal(@jis_str, @jis_str.kconv(::NKF::JIS)) end + def test_kconv + str = "\xc2\xa1" + %w/UTF-8 EUC-JP/.each do |enc| + s = str.dup.force_encoding(enc) + assert_equal(s, s.kconv(enc)) + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/