class Reline::Unicode
def self.get_mbchar_width(mbchar)
def self.get_mbchar_width(mbchar) ord = mbchar.ord if (0x00 <= ord and ord <= 0x1F) # in EscapedPairs return 2 elsif (0x20 <= ord and ord <= 0x7E) # printable ASCII chars return 1 end m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE) case when m.nil? then 1 # TODO should be U+FFFD � REPLACEMENT CHARACTER when m[:width_2_1], m[:width_2_2], m[:width_2_3] then 2 when m[:width_3] then 3 when m[:width_0] then 0 when m[:width_1] then 1 when m[:ambiguous_width] then Reline.ambiguous_width else nil end end