def METHOD_NAME(match):
    s = match.group(0)
    try:
        return ESCAPE_DICT[s]
    except KeyError:
        n = ord(s)
        if n < 0x10000:
            return '\\u%04x' % (n,)
        else:
            # surrogate pair
            n -= 0x10000
            s1 = 0xd800 | ((n >> 10) & 0x3ff)
            s2 = 0xdc00 | (n & 0x3ff)
            return '\\u%04x\\u%04x' % (s1, s2)