def uchr(c):
    if not isinstance(c, int):
        return c
    if c>255: return six.unichr(c)
    return chr(c)
예제 #2
0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255: return six.unichr(c)
    return chr(c)
예제 #3
0
        log.info(msg, *args)

    def warn(self, msg, *args):
        log.warn(msg, *args)

# This pattern matches a character entity reference (a decimal numeric
# references, a hexadecimal numeric reference, or a named reference).
entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub

def uchr(c):
    if not isinstance(c, int):
        return c
<<<<<<< HEAD
    if c>255: return unichr(c)
=======
    if c>255: return six.unichr(c)
>>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027
    return chr(c)

def decode_entity(match):
    what = match.group(1)
    if what.startswith('#x'):
        what = int(what[2:], 16)
    elif what.startswith('#'):
        what = int(what[1:])
    else:
<<<<<<< HEAD
        what = name2codepoint.get(what, match.group(0))
=======
        what = six.moves.html_entities.name2codepoint.get(what, match.group(0))
>>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027