def METHOD_NAME(self, text):
    """Replace characters with their character references.
    Replace characters by their named entity references.
    Non-ASCII characters, if they do not have a named entity reference,
    are replaced by numerical character references.
    The return value is guaranteed to be ASCII.
    """
    return self.__escapable.sub(self.__escape, str(text)).encode("ascii")