def handle_entityref(self, name): """ Process a named character reference. :param name: The name of the character reference (a string). """ self.output.write(unichr(name2codepoint[name]))
def handle_charref(self, value): """ Process a decimal or hexadecimal numeric character reference. :param value: The decimal or hexadecimal value (a string). """ self.output.write(unichr(int(value[1:], 16) if value.startswith('x') else int(value)))