Remove accents from String

Johann picture Johann · Dec 15, 2011 · Viewed 37.4k times · Source

Is there any way in Android that (to my knowledge) doesn't have java.text.Normalizer, to remove any accent from a String. E.g "éàù" becomes "eau".

I'd like to avoid parsing the String to check each character if possible!

Answer

Guillaume picture Guillaume · Dec 15, 2011

java.text.Normalizer is there in Android (on latest versions anyway). You can use it.

EDIT For reference, here is how to use Normalizer:

string = Normalizer.normalize(string, Normalizer.Form.NFD);
string = string.replaceAll("[^\\p{ASCII}]", "");

(pasted from the link in comments below)