def encode_html(unicode_data: str, encoding: str = 'ascii') -> bytes:
    """
    Encode unicode_data for use as XML or HTML, with characters outside
    of the encoding converted to XML numeric character references.
    """
    return unicode_data.encode(encoding, 'xmlcharrefreplace')