Created
June 22, 2018 22:26
-
-
Save lanbugs/4214f1e8aef550bf884344c8959f5356 to your computer and use it in GitHub Desktop.
Repair damaged UTF-8 string in python
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
#!/usr/bin/env python | |
name_kaputt = 'Gesch\xc3\xa4ftsstelle' | |
name = ''.join(chr(ord(c)) for c in name_kaputt).decode("utf-8") | |
print name_kaputt | |
print name | |
# Before: Geschäftsstelle | |
# Result: Geschäftsstelle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment