Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove accents from String

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!

like image 413
Johann Avatar asked Dec 15 '11 16:12

Johann


People also ask

How do I remove the accent from a string in Python?

We can remove accents from the string by using a Python module called Unidecode. This module consists of a method that takes a Unicode object or string and returns a string without ascents.

How do I remove the accent from a string in Java?

Use java. text. Normalizer to handle this for you. This will separate all of the accent marks from the characters.

How do you change an accented character to a regular character?

replace(/[^a-z0-9]/gi,'') . However a more intuitive solution (at least for the user) would be to replace accented characters with their "plain" equivalent, e.g. turn á , á into a , and ç into c , etc.


1 Answers

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)

like image 153
Guillaume Avatar answered Oct 13 '22 17:10

Guillaume