示例#1
0
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
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
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
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
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
def lookup(name):
    codepoint = UCharacter.getCharFromName(name)
    if codepoint == -1:
        raise KeyError("undefined character name '{}".format(name))
    return unichr(codepoint)
示例#7
0
def east_asian_width(unichr):
    return _eaw[UCharacter.getIntPropertyValue(_get_codepoint(unichr), UProperty.EAST_ASIAN_WIDTH)]
示例#8
0
def mirrored(unichr):
    return UCharacter.isMirrored(_get_codepoint(unichr))
示例#9
0
def combining(unichr):
    return UCharacter.getCombiningClass(_get_codepoint(unichr))
示例#10
0
def bidirectional(unichr):
    return _dir[UCharacter.getDirection(_get_codepoint(unichr))]
示例#11
0
def category(unichr):
    return _cat[UCharacter.getType(_get_codepoint(unichr))]