Skip to content

Instantly share code, notes, and snippets.

@vortec
Created December 19, 2013 17:20
Show Gist options
  • Select an option

  • Save vortec/8042922 to your computer and use it in GitHub Desktop.

Select an option

Save vortec/8042922 to your computer and use it in GitHub Desktop.
ALLOWED = {
unichr(9), # 0x09 - CHARACTER TABULATION (\t)
unichr(10), # 0x0A - LINE FEED (\n)
unichr(13) # 0x0D - CARRIAGE RETURN (\r)
}
DISALLOWED = set(map(unichr, range(0,32) + range(127,160))) | {
unichr(160) # 0x0A - NO-BREAK SPACE
}
BLACKLIST = frozenset({ char for char in DISALLOWED if char not in ALLOWED })
print BLACKLIST
## frozenset([u'\x81', u'\x00', u'\x83', u'\x02', u'\x85', u'\x04', u'\x87', u'\x06', u'\x89', u'\x08', u'\x8b', u'\x8a', u'\x8d', u'\x0c', u'\x8f', u'\x0e', u'\x91', u'\x10', u'\x93', u'\x12', u'\x95', u'\x14', u'\x97', u'\x16', u'\x99', u'\x18', u'\x9b', u'\x1a', u'\x9d', u'\x1c', u'\x9f', u'\x1e', u'\xa0', u'\x01', u'\x07', u'\x80', u'\x1d', u'\x86', u'\x17', u'\x9c', u'\x1f', u'\x88', u'\x05', u'\x9e', u'\x0b', u'\x96', u'\x8c', u'\x84', u'\x0f', u'\x1b', u'\x15', u'\x8e', u'\x11', u'\x03', u'\x90', u'\x9a', u'\x13', u'\x98', u'\x92', u'\x19', u'\x82', u'\x7f', u'\x94'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment