_illegal_ranges = [('%s-%s' % (chr(low), chr(high))) for low, high in
    _illegal_unichrs]
_illegal_xml_chars_RE = re.compile('[%s]' % ''.join(_illegal_ranges))
Fast way to filter illegal xml unicode chars in python?