diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-22 08:50:14 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-22 08:50:14 +0000 |
commit | 95a6be1a177976e75e06c1a8f55b438898bee3a2 (patch) | |
tree | 1cfdb935b9717ef55fc34e91e36f0074f0208993 /test/ruby/test_transcode.rb | |
parent | 9cda3a35b2cbe7d52798f5c23e0d1da17945acb2 (diff) |
* transcode.c (str_transcode0): don't scrub invalid chars if
str.encode doesn't have explicit invalid: :replace.
workaround fix for see #8995
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_transcode.rb')
-rw-r--r-- | test/ruby/test_transcode.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index db91010c94..25c9d24663 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -2071,4 +2071,13 @@ class TestTranscode < Test::Unit::TestCase assert_equal(4, 'aaa'.encode(enc).length, "should count in #{enc} with BOM") end end + + def test_encode_with_invalid_chars + bug8995 = '[ruby-dev:47747]' + EnvUtil.with_default_internal(Encoding::UTF_8) do + str = "\xff".force_encoding('utf-8') + assert_equal str, str.encode, bug8995 + assert_equal "\ufffd", str.encode(invalid: :replace), bug8995 + end + end end |