DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Converting Some French Chars With Python

09.07.2005
| 5694 views |
  • submit to reddit
        because translate and maketrans don't love utf-8 ;-(
    import string
    french=u"15 résultats trouvés".encode("utf_16")
    
    sfrom = u"àâäéèêëïîôöûùüç".encode("utf_16")
    sto   = u"aaaeeeeiioouuuc".encode("utf_16")
    print french.translate( string.maketrans(sfrom,sto) )