Advertisement
alvations

Remove Control Char

Feb 6th, 2014
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import unicodedata, re
  2.  
  3. all_chars = (unichr(i) for i in xrange(0x110000))
  4. control_chars = ''.join(c for c in all_chars if unicodedata.category(c)[0] == 'C')
  5. cc_re = re.compile('[%s]' % re.escape(control_chars))
  6. def rm_control_chars(s): # see http://www.unicode.org/reports/tr44/#General_Category_Values
  7.   return cc_re.sub('', s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement