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

StringremoveAccents(String str)
Remove acentos dos caracteres trocando eles por caracteres sem acentos.
str = Normalizer.normalize(str, Normalizer.Form.NFD);
str = str.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return str;
StringremoveAccents(String text)
remove Accents
return Normalizer.normalize(text, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
StringremoveAccents(String textWithAccent)
remove Accents
String normalizeFileName = Normalizer.normalize(textWithAccent, Normalizer.Form.NFD);
return normalizeFileName.replaceAll("[^\\p{ASCII}]", "");
StringremoveAccentsAndNonStandardCharacters(String string)
remove Accents And Non Standard Characters
String normalizedText = string;
if (NORMALIZE_METHOD != null) {
    try {
        normalizedText = (String) NORMALIZE_METHOD.invoke(null, string, NFD_VALUE);
    } catch (Exception ex) {
        normalizedText = string;
return CLEANUP_PATTERN.matcher(normalizedText).replaceAll("").toLowerCase();
StringremoveAccentuation(String str)
remove Accentuation
if (str == null || str.isEmpty() || str.matches("[\\w\\s\\.\\,\\;\\:\\!\\?\\+]*"))
    return str;
return Normalizer.normalize(str, Normalizer.Form.NFD).replaceAll("[\u0300-\u036f]", "");
StringreplaceAccent(String strInit)
This function converts French diacritics characters into non diacritics.
char charTest;
char[] tabTemp = strInit.toCharArray();
char[] voyelle = { 'a', 'c', 'e', 'i', 'o', 'u', 'y' };
Collator collator = Collator.getInstance(java.util.Locale.FRENCH);
collator.setStrength(Collator.PRIMARY);
for (int i = 0; i < strInit.length(); i++) {
    charTest = strInit.charAt(i);
    if ((charTest > 191) && (charTest < 256)) {
...
intreplaceAccentedChars(StringBuilder buffer)
replace Accented Chars
int sizeBefore = buffer.length();
String s = Normalizer.normalize(buffer, Normalizer.Form.NFD);
int sizeAfter = s.length();
int replaced = sizeAfter - sizeBefore;
if (replaced <= 0) {
    return 0;
s = s.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
...
StringreplaceAccents(String string)
replace Accents
String withoutAccent = Normalizer.normalize(string, Form.NFD).replaceAll(ASCII_REPLACEMENT, EMPTY_STRING);
if (withoutAccent.isEmpty() && !string.isEmpty())
    withoutAccent = string;
return withoutAccent;
StringstripAccents(final String input)

Removes diacritics (~= accents) from a string.

if (input == null) {
    return null;
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
final StringBuilder decomposed = new StringBuilder(Normalizer.normalize(input, Normalizer.Form.NFD));
convertRemainingAccentCharacters(decomposed);
return pattern.matcher(decomposed).replaceAll(EMPTY);
StringstripAccents(final String input)

Removes diacritics (~= accents) from a string.

if (input == null) {
    return null;
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
final String decomposed = Normalizer.normalize(input, Normalizer.Form.NFD);
return pattern.matcher(decomposed).replaceAll("");