summaryrefslogtreecommitdiff
path: root/lib/reline/config.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-04-20 12:00:08 +0900
committeraycabta <aycabta@gmail.com>2021-06-21 17:58:48 +0900
commitb0cc46b484028b65b3306e9d19803e49c7b7cd58 (patch)
tree1cdf469221dbcf57c12f8ce7690018a691f7e257 /lib/reline/config.rb
parentc59bbd86a6bd0f1ce8a7babf56feabeb41a7e675 (diff)
[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
Diffstat (limited to 'lib/reline/config.rb')
-rw-r--r--lib/reline/config.rb5
1 files changed, 4 insertions, 1 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)