4

How do I convert Æ and á into a regular English char with Java ? What I have is something like this : Local TV from Paraná. How to convert it to [Parana] ?

Frank
  • 29,646
  • 56
  • 159
  • 233

2 Answers2

6

Look at icu4j or the JDK 1.6 Normalizer:

public String removeAccents(String text) {
    return Normalizer.normalize(text, Normalizer.Form.NFD)
                     .replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
GAMA
  • 5,874
  • 13
  • 76
  • 124
bmargulies
  • 94,623
  • 39
  • 172
  • 299
0

As far as I know, there's no way to do this automatically -- you'd have to substitute manually using String.replaceAll.

String str = "Paraná";
str = str.replaceAll("á", "a");
str = str.replaceAll("Æ", "a");
Kaleb Brasee
  • 50,055
  • 8
  • 105
  • 112