SublimeTableEditor icon indicating copy to clipboard operation
SublimeTableEditor copied to clipboard

Use unicodedata module for detect wide characters

Open vkocubinsky opened this issue 12 years ago • 1 comments

vkocubinsky avatar Sep 15 '13 13:09 vkocubinsky

There is new content of widechar_support, but it is doesn't work on ST2 under windows

import unicodedata
import sys
import locale

def wcount(text):
    if sys.version_info[0] == 2 and isinstance(text, str):
        text = unicode(text, locale.getpreferredencoding())

    return len([x for x in text if unicodedata.east_asian_width(x) == 'W'])


def wlen(text):
    return len(text) + wcount(text)

vkocubinsky avatar Sep 23 '13 07:09 vkocubinsky