Java Utililty Methods String Accent

List of utility methods to do String Accent

Description

The list of methods to do String Accent are organized into topic(s).

Method

intcompareIgnoreCaseAndAccent(String string1, String string2, Locale locale)
Performs a string comparison ignoring case and accent.
if (string1 == null || string2 == null) {
    if (string1 == null && string2 == null)
        return 0;
    if (string1 == null)
        return -1;
    return 1;
Collator collator = Collator.getInstance(locale);
...
StringdeAccent(final @Nonnull String string)
See http://stackoverflow.com/questions/1008802/converting-symbols-accent-letters-to-english-alphabet
final String nfdNormalizedString = java.text.Normalizer.normalize(string, java.text.Normalizer.Form.NFD);
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
return pattern.matcher(nfdNormalizedString).replaceAll("");
StringdeAccent(String str)
de Accent
if (str == null)
    return null;
String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
return pattern.matcher(nfdNormalizedString).replaceAll("");
StringdeAccent(String str)
de Accent
String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
return pattern.matcher(nfdNormalizedString).replaceAll("");
StringdeAccent(String str)
Removing diacritical marks aka accents
String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); 
return pattern.matcher(nfdNormalizedString).replaceAll(""); 
StringdeleteAccents(String text)
Remove accents from string
String nfdNormalizedString = Normalizer.normalize(text, Normalizer.Form.NFD);
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
text = pattern.matcher(nfdNormalizedString).replaceAll("");
return text;
booleanequalsIgnoreAccents(String lhs, String rhs, Locale locale)
equals Ignore Accents
Collator collator = Collator.getInstance(locale);
collator.setStrength(Collator.PRIMARY);
int comparison = collator.compare(lhs, rhs);
return (comparison == 0);
booleanequalsIgnoreAccentsAndCase(String s1, String s2)
equals Ignore Accents And Case
return equalsIgnoreAccents(s1.toLowerCase(), s2.toLowerCase());
booleanequalsIgnoreCaseAndAccent(String string1, String string2, Locale locale)
equals Ignore Case And Accent
return compareIgnoreCaseAndAccent(string1, string2, locale) == 0;
booleanequalsStringIgnoringAccents(String str1, String str2)
equals String Ignoring Accents
final Collator instance = Collator.getInstance();
instance.setStrength(Collator.NO_DECOMPOSITION);
if (instance.compare(str1, str2) == 0) {
    return true;
} else {
    return false;