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:
parent
729b7ce270
commit
778634f778
1 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue