From b0cc46b484028b65b3306e9d19803e49c7b7cd58 Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 20 Apr 2021 12:00:08 +0900 Subject: [ruby/reline] The config file must accept any character encoding In Japan, so many programmers used EUC-JP to write text files that contain Japanese. Many .inputrc files which contain EUC-JP are still being copied and used. This commit supports the whole encoding of what user set including UTF-8. ref. https://github.com/ruby/reline/pull/280 https://github.com/ruby/reline/commit/0b45022e16 --- lib/reline/config.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/reline/config.rb') 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) -- cgit v1.2.3