def mk_wcwidth()

in cqlsh-expansion/pylib/cqlshlib/wcwidth.py [0:0]


def mk_wcwidth(ucs):
    # test for 8-bit control characters
    if ucs == 0:
        return 0
    if ucs < 32 or (ucs >= 0x7f and ucs < 0xa0):
        return -1

    # binary search in table of non-spacing characters
    if bisearch(ucs, combining):
        return 0

    # if we arrive here, ucs is not a combining or C0/C1 control character

    return 1 + \
        int(ucs >= 0x1100 and
            (ucs <= 0x115f or                     # Hangul Jamo init. consonants
             ucs == 0x2329 or ucs == 0x232a or
             (ucs >= 0x2e80 and ucs <= 0xa4cf and
              ucs != 0x303f) or                   # CJK ... Yi
                (ucs >= 0xac00 and ucs <= 0xd7a3) or  # Hangul Syllables
                (ucs >= 0xf900 and ucs <= 0xfaff) or  # CJK Compatibility Ideographs
                (ucs >= 0xfe10 and ucs <= 0xfe19) or  # Vertical forms
                (ucs >= 0xfe30 and ucs <= 0xfe6f) or  # CJK Compatibility Forms
                (ucs >= 0xff00 and ucs <= 0xff60) or  # Fullwidth Forms
                (ucs >= 0xffe0 and ucs <= 0xffe6) or
                (ucs >= 0x20000 and ucs <= 0x2fffd) or
                (ucs >= 0x30000 and ucs <= 0x3fffd)))