Created
May 3, 2010 17:31
-
-
Save luispedro/388348 to your computer and use it in GitHub Desktop.
is_ascii
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_ascii(s): | |
''' | |
ascii = is_ascii(s) | |
Check whether a unicode string is ASCII | |
''' | |
try: | |
s = s.encode('ascii') | |
return True | |
except UnicodeError: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment