Created
May 10, 2012 16:29
-
-
Save mrpollo/2654309 to your computer and use it in GitHub Desktop.
python unicode from latin charmap UnicodeError
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
| a = u'Teresa de Jes\xc3\u0192\xc2\xbas Galicia G\xc3\u0192\xc2\xb3mez' | |
| b = u'EMMANUEL PE\xc3\u0192\xc2\u2018A GOMEZ PORTUGAL' | |
| c = u'DR. JOS\xc3\u0192\xc2\u2030 ABEN\xc3\u0192\xc2\x81MAR RIC\xc3\u0192\xc2\x81RDEZ GARC\xc3\u0192\xc2\x8dA' | |
| print a | |
| print a.encode('cp1252').decode('utf-8').encode('cp1252').decode('utf-8') | |
| print b | |
| print b.encode('cp1252').decode('utf-8').encode('cp1252').decode('utf-8') | |
| print c | |
| print c.encode('cp1252').decode('utf-8').encode('cp1252').decode('utf-8') |
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
| Teresa de Jesús Galicia Gómez | |
| Teresa de Jesús Galicia Gómez | |
| EMMANUEL PEÑA GOMEZ PORTUGAL | |
| Traceback (most recent call last): | |
| File "regex.py", line 12, in <module> | |
| print b.encode('cp1252').decode('utf-8').encode('cp1252').decode('utf-8') | |
| File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/cp1252.py", line 12, in encode | |
| return codecs.charmap_encode(input,errors,encoding_table) | |
| UnicodeEncodeError: 'charmap' codec can't encode character u'\x91' in position 12: character maps to <undefined> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment