Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

Use unicodedata module for detect wide characters #32

Open
vkocubinsky opened this issue Sep 15, 2013 · 1 comment
Open

Use unicodedata module for detect wide characters #32

vkocubinsky opened this issue Sep 15, 2013 · 1 comment

Comments

@vkocubinsky
Copy link
Owner

No description provided.

@vkocubinsky
Copy link
Owner Author

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant