summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-10 01:57:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-10 01:57:10 +0000
commitf9a5335ed4f84e6e3ed23cb92966a36101d9d149 (patch)
tree8ddbd447fd245dfb2377047fda71cde13f94e408 /test
parent47c64fdf5447bdde3de074855e4867a349f4a3b5 (diff)
csv.rb: honor encoding option
* lib/csv.rb (CSV#<<): honor explicity given encoding. based on the patch by DAISUKE TANIWAKI <daisuketaniwaki AT gmail.com> at [ruby-core:62113]. [Bug #9766] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rwxr-xr-xtest/csv/test_encodings.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/csv/test_encodings.rb b/test/csv/test_encodings.rb
index 21b997c9ec4..dc45692ce48 100755
--- a/test/csv/test_encodings.rb
+++ b/test/csv/test_encodings.rb
@@ -247,6 +247,14 @@ class TestCSV::Encodings < TestCSV
assert_equal("UTF-8", data.to_csv.encoding.name)
end
+ def test_explicit_encoding
+ bug9766 = '[ruby-core:62113] [Bug #9766]'
+ s = CSV.generate(encoding: "Windows-31J") do |csv|
+ csv << ["foo".force_encoding("ISO-8859-1"), "\u3042"]
+ end
+ assert_equal(["foo,\u3042\n".encode(Encoding::Windows_31J), Encoding::Windows_31J], [s, s.encoding], bug9766)
+ end
+
private
def assert_parses(fields, encoding, options = { })