0

I am trying to look for a way to compare two Strings without taking into consideration their letter accents and case.

I am parsing a large document with many names in different languages and sometimes users forget to add the accents, are just lazy to add the accents to their names, or the fact that the same name in different languages is spelled with the same letters but without the accent.

So for example, "COTE D'IVOIRE" = "Côte d'Ivoire" will be true.

I know Java has a built in .equalsIgnoreCase but how do I compare accents while ignoring accents AND case?

Kingamere
  • 9,496
  • 23
  • 71
  • 110

1 Answers1

0

you could 1st strip out all the accents using a Normalizer (see this question) and then compare ignoring case.

EDIT - or, as user @lbarros pointed out, a Collator would work even better

Community
  • 1
  • 1
radai
  • 23,949
  • 10
  • 71
  • 115
  • Actually I think the Normalizer class would work better as stated in this question: http://stackoverflow.com/questions/2397804/java-string-searching-ignoring-accents since Collator is better for sorting and not equality comparison. – Kingamere May 07 '16 at 20:53
  • 1
    @Kingamere - comparison is a superset of equality, but either way one of those should work for you – radai May 07 '16 at 21:23