I have a list with some Belgian cities with diacritic characters: (Liège, Quiévrain, Franière, etc.) and I would like to transform these special characters to compare with a lis
If you still need that for Android API 8 or lower (Android 2.2, Java 1.5) where you don't have Normalizer class, here's my code, I think better to modify than Pentium10 answer:
public class StringAccentRemover {
@SuppressWarnings("serial")
private static final HashMap accents = new HashMap(){
{
put('Ą', 'A');
put('Ę', 'E');
put('Ć', 'C');
put('Ł', 'L');
put('Ń', 'N');
put('Ó', 'O');
put('Ś', 'S');
put('Ż', 'Z');
put('Ź', 'Z');
put('ą', 'a');
put('ę', 'e');
put('ć', 'c');
put('ł', 'l');
put('ń', 'n');
put('ó', 'o');
put('ś', 's');
put('ż', 'z');
put('ź', 'z');
}
};
/**
* remove accented from a string and replace with ascii equivalent
*/
public static String removeAccents(String s) {
char[] result = s.toCharArray();
for(int i=0; i