ranges = [(0, 8), (11, 31), (127, 132), (134, 159), (55296, 57343), (64976,
    64991), (65534, 65535)]
nukemap = dict.fromkeys(r for start, end in ranges for r in range(start, 
    end + 1))
Fast way to filter illegal xml unicode chars in python?