Last active
November 14, 2018 12:08
-
-
Save bismarckjunior/d7df37dcc9df95dfb315b7c09758c0d0 to your computer and use it in GitHub Desktop.
Remove accents from text. E.g.: "ÃÊÍÒÜ-ãêíòü" -> "AEIOU-aeiou"
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
# -*- coding: utf-8 -*- | |
import sys, unicodedata | |
reload(sys) | |
sys.setdefaultencoding("utf-8") | |
# sys.setdefaultencoding("cp1252") | |
def remove_accents(txt): | |
# Returns a string without accents | |
return unicodedata.normalize('NFKD', unicode(txt)).encode('ASCII', 'ignore') | |
if __name__ == '__main__': | |
print remove_accents(u'ÃÊÍÒÜ-ãêíòü') # Out: AEIOU-aeiou |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment