Created
April 20, 2014 17:22
-
-
Save Snawoot/11119706 to your computer and use it in GitHub Desktop.
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
if isinstance(s, str): | |
if all([ord(c) in range(0,128) for c in s]): | |
#handle as ascii | |
else: | |
#handle CP1251 (.decode("cp1251").encode("utf-8") or drop nationa chars) | |
elif isinstance(s, unicode): | |
#handle as unicode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment