mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add and use Reline::Unicode.escape_for_print
This commit is contained in:
parent
e691b4da5d
commit
e2db9f4cc3
4 changed files with 25 additions and 7 deletions
|
@ -55,6 +55,17 @@ class Reline::Unicode
|
|||
end
|
||||
end
|
||||
|
||||
def self.escape_for_print(str)
|
||||
str.chars.map! { |gr|
|
||||
escaped = EscapedPairs[gr.ord]
|
||||
if escaped && gr != "\n"
|
||||
escaped
|
||||
else
|
||||
gr
|
||||
end
|
||||
}.join
|
||||
end
|
||||
|
||||
def self.get_mbchar_width(mbchar)
|
||||
case mbchar.encode(Encoding::UTF_8)
|
||||
when *EscapedChars # ^ + char, such as ^M, ^H, ^[, ...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue