List of utility methods to do String Accent
int | compareIgnoreCaseAndAccent(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); ... |
String | deAccent(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(""); |
String | deAccent(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(""); |
String | deAccent(String str) de Accent String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD); Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); return pattern.matcher(nfdNormalizedString).replaceAll(""); |
String | deAccent(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(""); |
String | deleteAccents(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; |
boolean | equalsIgnoreAccents(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); |
boolean | equalsIgnoreAccentsAndCase(String s1, String s2) equals Ignore Accents And Case return equalsIgnoreAccents(s1.toLowerCase(), s2.toLowerCase());
|
boolean | equalsIgnoreCaseAndAccent(String string1, String string2, Locale locale) equals Ignore Case And Accent return compareIgnoreCaseAndAccent(string1, string2, locale) == 0;
|
boolean | equalsStringIgnoringAccents(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; |