diff options
author | aycabta <aycabta@gmail.com> | 2020-01-12 22:24:17 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-01-14 15:40:38 +0900 |
commit | f8ea2860b0cac1aec79978e6c44168802958e8af (patch) | |
tree | c34b0ee9cd9d6b2b7a4fc494d0f9563a7ce97968 /lib/reline/windows.rb | |
parent | c94025b63091be5b5e83a2f5ab5dc8d6c6147b84 (diff) |
Introduce an abstracted structure about the encoding of Reline
The command prompt on Windows always uses Unicode to take input and print
output but most Reline implementation depends on Encoding.default_external.
This commit introduces an abstracted structure about the encoding of Reline.
Diffstat (limited to 'lib/reline/windows.rb')
-rw-r--r-- | lib/reline/windows.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb index aef3073a7e..4fbf243c37 100644 --- a/lib/reline/windows.rb +++ b/lib/reline/windows.rb @@ -1,6 +1,10 @@ require 'fiddle/import' class Reline::Windows + def self.encoding + Encoding::UTF_8 + end + RAW_KEYSTROKE_CONFIG = { [224, 72] => :ed_prev_history, # ↑ [224, 80] => :ed_next_history, # ↓ @@ -99,7 +103,7 @@ class Reline::Windows return @@input_buf.shift end begin - bytes = ret.chr(Encoding::UTF_8).encode(Encoding.default_external).bytes + bytes = ret.chr(Encoding::UTF_8).bytes @@input_buf.push(*bytes) rescue Encoding::UndefinedConversionError @@input_buf << ret |