Java String Accent stripAccentsToLowerCase(String str)

Here you can find the source of stripAccentsToLowerCase(String str)

Description

Remove all accents in the string provided.

License

Open Source License

Parameter

Parameter Description
str the string

Return

a string without accents.

Declaration

public static String stripAccentsToLowerCase(String str) 

Method Source Code


//package com.java2s;
/*/*from   w  w  w.j av  a 2 s . c o m*/
 * Copyright ? WebServices pour l'?ducation, 2014
 *
 * This file is part of ENT Core. ENT Core is a versatile ENT engine based on the JVM.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation (version 3 of the License).
 *
 * For the sake of explanation, any module that communicate over native
 * Web protocols, such as HTTP, with ENT Core is outside the scope of this
 * license and could be license under its own terms. This is merely considered
 * normal use of ENT Core, and does not fall under the heading of "covered work".
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

import java.text.Normalizer;

public class Main {
    /**
     * Remove all accents in the string provided.
     *
     * @param str the string
     *
     * @return a string without accents.
     */
    public static String stripAccentsToLowerCase(String str) {
        return stripAccents(str).toLowerCase();
    }

    /**
     * Remove all accents in the string provided.
     *
     * @param str the string
     *
     * @return a string without accents.
     */
    public static String stripAccents(String str) {
        String strUnaccent = Normalizer.normalize(str, Normalizer.Form.NFD);
        strUnaccent = strUnaccent.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
        return strUnaccent;
    }
}

Related

  1. stripAccents(final String s)
  2. stripAccents(String input)
  3. stripAccents(String input)
  4. stripAccents(String input)
  5. stripAccents(String v)
  6. toLatinUnaccented(String s)
  7. toUnaccented(String s)