diff options
Diffstat (limited to 'lib/reline')
-rw-r--r-- | lib/reline/config.rb | 5 | ||||
-rw-r--r-- | lib/reline/general_io.rb | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb index dd81a23ea7..ed5061f802 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -158,6 +158,9 @@ class Reline::Config end def read_lines(lines, file = nil) + if lines.first.encoding != Reline.encoding_system_needs + lines = lines.map { |l| l.encode(Reline.encoding_system_needs) } + end conditions = [@skip_section, @if_stack] @skip_section = nil @if_stack = [] @@ -293,7 +296,7 @@ class Reline::Config def retrieve_string(str) str = $1 if str =~ /\A"(.*)"\z/ - parse_keyseq(str).map { |c| c.chr(Reline::IOGate.encoding) }.join + parse_keyseq(str).map { |c| c.chr(Reline.encoding_system_needs) }.join end def bind_key(key, func_name) diff --git a/lib/reline/general_io.rb b/lib/reline/general_io.rb index 8c8e22d2e6..4f605628a3 100644 --- a/lib/reline/general_io.rb +++ b/lib/reline/general_io.rb @@ -1,12 +1,19 @@ require 'timeout' class Reline::GeneralIO - def self.reset + def self.reset(encoding: nil) @@pasting = false + @@encoding = encoding end def self.encoding - RUBY_PLATFORM =~ /mswin|mingw/ ? Encoding::UTF_8 : Encoding::default_external + if @@encoding + @@encoding + elsif RUBY_PLATFORM =~ /mswin|mingw/ + Encoding::UTF_8 + else + Encoding::default_external + end end def self.win? |