human
I wrote the below code

    def check(ch):
        return result_exceptions.get(ch, ch)
    ent = match.group(1)
    if (ent in exceptions):
        return (('&' + ent) + ';')
    if (ent in {'apos', 'squot'}):
        return check("'")
    if (ent == 'hellips'):
        ent = 'hellip'
    if ent.startswith('#'):
        try:
            if (ent[1] in ('x', 'X')):
                num = int(ent[2:], 16)
            else:
                num = int(ent[1:])
        except:
            return (('&' + ent) + ';')
        if ((encoding is None) or (num > 255)):
            return check(my_unichr(num))
        try:
            return check(chr(num).decode(encoding))
        except UnicodeDecodeError:
            return check(my_unichr(num))
    from calibre.ebooks.html_entities import html5_entities
    try:
        return check(html5_entities[ent])
    except KeyError:
        pass
    from htmlentitydefs import name2codepoint
    try:
        return check(my_unichr(name2codepoint[ent]))
    except KeyError:
        return (('&' + ent) + ';')

What's a good function header?

=====
Here's a good function header?
assistant
#Here's a good function header.

def entity_to_unicode(match, exceptions=[], encoding='cp1252', result_exceptions={}):