Skip to content

Instantly share code, notes, and snippets.

@Snawoot
Created April 20, 2014 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Snawoot/11119706 to your computer and use it in GitHub Desktop.
Save Snawoot/11119706 to your computer and use it in GitHub Desktop.
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