'Replace characters with their character entity references.
Only characters corresponding to a named entity are replaced.'

def escape_entities(self, text):

    return compat.text_type(text).translate(self.codepoint2entity)
