diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 9689c8f51d..dd81a23ea7 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -292,11 +292,8 @@ class Reline::Config end def retrieve_string(str) - if str =~ /\A"(.*)"\z/ - parse_keyseq($1).map(&:chr).join - else - parse_keyseq(str).map(&:chr).join - end + str = $1 if str =~ /\A"(.*)"\z/ + parse_keyseq(str).map { |c| c.chr(Reline::IOGate.encoding) }.join end def bind_key(key, func_name) diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index 2cca0e71f7..2ada00c154 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -286,6 +286,16 @@ class Reline::Config::Test < Reline::TestCase ENV['INPUTRC'] = inputrc_backup end + def test_inputrc_with_utf + @config.read_lines(<<~'LINES'.lines) + set editing-mode vi + set vi-cmd-mode-string 🍸 + set vi-ins-mode-string 🍶 + LINES + assert_equal @config.vi_cmd_mode_string, "🍸" + assert_equal @config.vi_ins_mode_string, "🍶" + end + def test_xdg_config_home home_backup = ENV['HOME'] xdg_config_home_backup = ENV['XDG_CONFIG_HOME']