vkocubinsky / SublimeTableEditor

This package is no more supported. I moved to vim.
Other
494 stars 67 forks source link

Use unicodedata module for detect wide characters #32

Open vkocubinsky opened 11 years ago

vkocubinsky commented 11 years ago

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)