Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve external encoding of stdin on windows #1042

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/irb/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,14 @@ def set_encoding(extern, intern = nil, override: true)
Encoding.default_external = extern unless extern.nil? || extern.empty?
Encoding.default_internal = intern unless intern.nil? || intern.empty?
[$stdin, $stdout, $stderr].each do |io|
io.set_encoding(extern, intern)
if io.tty? && io.internal_encoding && /mswin|mingw/ =~ RUBY_PLATFORM
# some ruby versions, $stdin has locale:UTF-8 encoding by default on windows.
# preserve external_encoding in that case.
io.set_encoding(io.external_encoding, (intern.nil? || intern.empty?) ? extern : intern)
next
else
io.set_encoding(extern, intern)
end
end
if override
@CONF[:LC_MESSAGES].instance_variable_set(:@override_encoding, extern)
Expand Down
Loading