Nicolas Bouliane

How to replace accented characters in a Javascript string

Posted on

If you are dealing with international user, you will sometimes need to replace unicode characters (éåü) with their ascii counterparts (eau).

The easiest way is to use a small library called stringops. It extends the String prototype to give your strings the .noAccents method. For instance, you can do "éåü".noAccents() and you will get "eau".

The library is very lightweight, but features other useful utilities to deal with strings. The full documentation is available on its github page, along with examples.