Zionetrix::Git
Repositories
Help
Report an Issue
thunderbird2sogo
Code
Commits
Branches
Tags
Search
Tree:
4b2682d
Branches
Tags
master
thunderbird2sogo
replace_accents.py
Initial commit
Benjamin Renard
commited
4b2682d
at 2013-12-25 20:10:39
replace_accents.py
Blame
History
Raw
#!/usr/bin/python # -*- coding: utf-8 -*- # # This simple library provide function to replace accents # in string. It's part of thunderbird2sogo scripts. # # Author : Benjamin Renard <brenard@zionetrix.net> # Date : Wed, 25 Dec 2013 20:41:39 +0100 # Source : http://git.zionetrix.net/thunderbird2sogo import string def replace_accents(s): replacements={ "à": "a", "á": "a", "â": "a", "ã": "a", "ä": "a", "ç": "c", "è": "e", "é": "e", "ê": "e", "ë": "e", "ì": "i", "í": "i", "î": "i", "ï": "i", "ñ": "n", "ò": "o", "ó": "o", "ô": "o", "õ": "o", "ö": "o", "ù": "u", "ú": "u", "û": "u", "ü": "u", "ý": "y", "ÿ": "y", "À": "A", "Á": "A", "Â": "A", "Ã": "A", "Ä": "A", "Ç": "C", "È": "E", "É": "E", "Ê": "E", "Ë": "E", "Ì": "I", "Í": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ò": "O", "Ó": "O", "Ô": "O", "Õ": "O", "Ö": "O", "Ù": "U", "Ú": "U", "Û": "U", "Ü": "U", "Ý": "Y" } for f in replacements: s=s.replace(f,replacements[f]) return s if __name__ == '__main__': test='éàèôù' print '%s -> %s' % (test,replace_accents(test))