Created
          October 24, 2011 08:07 
        
      - 
      
- 
        Save nailor/1308566 to your computer and use it in GitHub Desktop. 
    Deaccent unicode strings
  
        
  
    
      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
    
  
  
    
  | # 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