1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Restore the external and internal encodings of STDIN, STDOUT, and STDERR

IRB::ReadlineInputMethod#initialize changes them via IRB.set_encoding.
This commit is contained in:
Yusuke Endoh 2020-05-08 00:19:54 +09:00
parent 3b147c4213
commit 1084b679bd

View file

@ -18,6 +18,7 @@ module TestIRB
@home_backup = ENV["HOME"]
ENV["HOME"] = @tmpdir
@default_encoding = [Encoding.default_external, Encoding.default_internal]
@stdio_encodings = [STDIN, STDOUT, STDERR].map {|io| [io.external_encoding, io.internal_encoding] }
IRB.instance_variable_get(:@CONF).clear
end
@ -27,6 +28,9 @@ module TestIRB
FileUtils.rm_rf(@tmpdir)
EnvUtil.suppress_warning {
Encoding.default_external, Encoding.default_internal = *@default_encoding
[STDIN, STDOUT, STDERR].zip(@stdio_encodings) do |io, encs|
io.set_encoding(*encs)
end
}
end