Possible Duplicates:
Java. Ignore accents when comparing strings
Java string searching ignoring accents
Hi All
I need to compare strings in java that might be like 'Chloe' and 'Chloé'. I need them to be equal. Anyone knows what the best practice is ? Or is there some third-party library ?
Roman
Have a look at International Components for Unicode, it can do what you need.
Edit: here's some sample code to get you started (from the Collator Javadoc):
// Get the Collator for US English and set its strength to PRIMARY
Collator usCollator = Collator.getInstance(Locale.US);
usCollator.setStrength(Collator.PRIMARY);
if (usCollator.compare("abc", "ABC") == 0) {
System.out.println("Strings are equivalent");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With