Skip to content

Instantly share code, notes, and snippets.

@lanbugs
Created June 22, 2018 22:26
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 lanbugs/4214f1e8aef550bf884344c8959f5356 to your computer and use it in GitHub Desktop.
Save lanbugs/4214f1e8aef550bf884344c8959f5356 to your computer and use it in GitHub Desktop.
Repair damaged UTF-8 string in python
#!/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