Skip to content

Instantly share code, notes, and snippets.

@dvreed77
Created November 9, 2017 15:45
Show Gist options
  • Save dvreed77/6d6abc061a53f0127fe4380bd6a26a33 to your computer and use it in GitHub Desktop.
Save dvreed77/6d6abc061a53f0127fe4380bd6a26a33 to your computer and use it in GitHub Desktop.
a = 'CURAÌàAO'
def normalize_str(x):
if type(x) != unicode:
encoding = "utf-8" # or iso-8859-15, or cp1252, or whatever encoding you use
byte_string = bytes(x) # or simply "café" before python 3.
unicode_string = byte_string.decode(encoding)
else:
unicode_string = x
return unicodedata.normalize('NFD', unicode_string).encode('ascii','ignore')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment