Skip to content

Instantly share code, notes, and snippets.

@nailor
Created October 24, 2011 08:07
Show Gist options
  • Save nailor/1308566 to your computer and use it in GitHub Desktop.
Save nailor/1308566 to your computer and use it in GitHub Desktop.
Deaccent unicode strings
# Deaccent unicode strings.
#
# unicodedata.normalize('NFKD', unicodestring): do a compatibility
# decomposition of the unicode string
#
# unicodedata.category(somecharacter): Find the unicode category
# for a character. Category 'Mn' contains all combining accents
import unicodedata
def deaccent(some_unicode_string):
return u''.join(c for c in unicodedata.normalize('NFD', some_unicode_string)
if unicodedata.category(c) != 'Mn')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment