Created
March 17, 2014 13:44
-
-
Save silviud/9599403 to your computer and use it in GitHub Desktop.
Encode utf python
This file contains hidden or 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 try_utf8(data): | |
"Returns a Unicode object on success, or None on failure" | |
try: | |
return data.decode('utf-8') | |
except UnicodeDecodeError, ue: | |
print ue | |
return None | |
# vim e! ++enc=utf8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment