I know that to check whether a string is printable, we can do something like:
def isprintable(s,codec='utf8'):
try:
s.codec(codec)
except UnicodeDecodeError:
return False
else:
return True
But is there a way to do it with Unicode, not a string?
Btw, I’m working with tweets, and I convert the tweets to Unicode as follows
text=unicode(status.text)
You are looking for a test for a range of codepoints, so you need a regular expression:
This will return
Falsefor any unicode text that has codepoints past\u00BE(“¾”).