[ruby/stringio] StringIO#initialize default to the source string encoding

[Bug #16497]

4958a5ccab
(cherry picked from commit e257c08f2e)
This commit is contained in:
Jean Boussier 2020-03-12 13:55:20 +01:00 committed by NARUSE, Yui
parent 3efbd527a8
commit 47b08728cf
3 changed files with 21 additions and 4 deletions

View file

@ -797,6 +797,18 @@ class TestStringIO < Test::Unit::TestCase
end
end
def test_binary_encoding_read_and_default_internal
verbose, $VERBOSE = $VERBOSE, nil
default_internal = Encoding.default_internal
Encoding.default_internal = Encoding::UTF_8
$VERBOSE = verbose
assert_equal Encoding::BINARY, StringIO.new("Hello".b).read.encoding
ensure
$VERBOSE = nil
Encoding.default_internal = default_internal
$VERBOSE = verbose
end
def assert_string(content, encoding, str, mesg = nil)
assert_equal([content, encoding], [str, str.encoding], mesg)
end