コード例 #1
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def _get_decomp_type(unichr):
    if unichr == u"\u2044":  # FRACTION SLASH
        # special case this for CPython compatibility even though this returns as not being combining, eg, see
        # http://www.fileformat.info/info/unicode/char/2044/index.htm
        return "fraction"
    else:
        return _decomp[UCharacter.getIntPropertyValue(ord(unichr), UProperty.DECOMPOSITION_TYPE)]
コード例 #2
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def numeric(unichr, default=Nonesuch):
    n = UCharacter.getUnicodeNumericValue(_get_codepoint(unichr))
    if n == UCharacter.NO_NUMERIC_VALUE:
        if default is not Nonesuch:
            return default
        else:
            raise ValueError("not a numeric")
    return n
コード例 #3
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def decimal(unichr, default=Nonesuch):
    d = UCharacter.getNumericValue(_get_codepoint(unichr))
    if d < 0 or d > 9:
        if default is not Nonesuch:
            return default
        else:
            raise ValueError("not a decimal")
    return d
コード例 #4
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def digit(unichr, default=Nonesuch):
    d = UCharacter.digit(_get_codepoint(unichr))
    if d == -1:
        if default is not Nonesuch:
            return default
        else:
            raise ValueError("not a digit")
    return d
コード例 #5
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def name(unichr, default=Nonesuch):
    # handle None
    n = UCharacter.getName(_get_codepoint(unichr))
    if n is None:
        if default is not Nonesuch:
            return default
        else:
            raise ValueError("no such name")
    return n
コード例 #6
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def lookup(name):
    codepoint = UCharacter.getCharFromName(name)
    if codepoint == -1:
        raise KeyError("undefined character name '{}".format(name))
    return unichr(codepoint)
コード例 #7
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def east_asian_width(unichr):
    return _eaw[UCharacter.getIntPropertyValue(_get_codepoint(unichr), UProperty.EAST_ASIAN_WIDTH)]
コード例 #8
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def mirrored(unichr):
    return UCharacter.isMirrored(_get_codepoint(unichr))
コード例 #9
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def combining(unichr):
    return UCharacter.getCombiningClass(_get_codepoint(unichr))
コード例 #10
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def bidirectional(unichr):
    return _dir[UCharacter.getDirection(_get_codepoint(unichr))]
コード例 #11
0
ファイル: unicodedata.py プロジェクト: evaimg/Icy-App
def category(unichr):
    return _cat[UCharacter.getType(_get_codepoint(unichr))]