1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Determine 1st char or 2nd char of surrogate pair correctly

https://github.com/ruby/reline/commit/182606c847
This commit is contained in:
aycabta 2021-12-24 13:58:19 +09:00 committed by git
parent 6050e3e2a6
commit 3a59abab08

View file

@ -220,12 +220,12 @@ class Reline::Windows
def self.process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
# high-surrogate
if char_code & 0xDC00 == 0xD800
if 0xD800 <= char_code and char_code <= 0xDBFF
@@hsg = char_code
return
end
# low-surrogate
if char_code & 0xDC00 == 0xDC00
if 0xDC00 <= char_code and char_code <= 0xDFFF
if @@hsg
char_code = 0x10000 + (@@hsg - 0xD800) * 0x400 + char_code - 0xDC00
@@hsg = nil