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
  • 28,342
  • 54
  • 158
  • 227

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,694
  • 13
  • 75
  • 122
bmargulies
  • 91,317
  • 38
  • 166
  • 290
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
  • 48,461
  • 8
  • 103
  • 110