Skip to content
Browse files

* ext/nkf/lib/kconv.rb (String#kconv): fix typo and update rdoc.

  patched by Kouhei Yanagita [ruby-dev:42696]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 1f70a6b commit 85eb93d062934ef711074ec6bd1eaab33fed64aa @nurse nurse committed Dec 7, 2010
Showing with 17 additions and 5 deletions.
  1. +5 −0 ChangeLog
  2. +5 −5 ext/nkf/lib/kconv.rb
  3. +7 −0 test/nkf/test_kconv.rb
View
5 ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec 7 18:56:52 2010 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@cozmixng.org>
* test/rexml/test_doctype.rb: add Accessor to test case name.
View
10 ext/nkf/lib/kconv.rb
@@ -51,8 +51,8 @@ module Kconv
# 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 @@ class String
# 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
View
7 test/nkf/test_kconv.rb
@@ -71,4 +71,11 @@ def test_jis
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

0 comments on commit 85eb93d

Please sign in to comment.
Something went wrong with that request. Please try again.