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

Drop an invalid char as UTF-8

This commit is contained in:
aycabta 2019-12-27 16:02:07 +09:00
parent 729b7ce270
commit 778634f778

View file

@ -1091,6 +1091,11 @@ class Reline::LineEditor
private def ed_insert(key)
if key.instance_of?(String)
begin
key.encode(Encoding::UTF_8)
rescue Encoding::UndefinedConversionError
return
end
width = Reline::Unicode.get_mbchar_width(key)
if @cursor == @cursor_max
@line += key
@ -1101,6 +1106,11 @@ class Reline::LineEditor
@cursor += width
@cursor_max += width
else
begin
key.chr.encode(Encoding::UTF_8)
rescue Encoding::UndefinedConversionError
return
end
if @cursor == @cursor_max
@line += key.chr
else