Replace accented chars with unaccented ones

Josiah Carlson jcarlson at nospam.uci.edu
Tue Mar 16 17:16:12 EST 2004


> Using the .translate() method on unicode strings should be
> even more performant:
> 
> # prepare mapping table to match .translate interface
> table = {}
> for k,v in replacement_pairs: table[ord(k)]=v
> 
> def multi_replace(inp):
>   return inp.translate(table)

Even better *smile*.

  - Josiah



More information about the Python-list mailing list