#!/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 # 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))