Java String Accent deAccent(String str)

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

Description

Removing diacritical marks aka accents

License

Open Source License

Parameter

Parameter Description
str a parameter

Return

the input string without accents

Declaration

public static String deAccent(String str) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 Weasis Team and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*w  w  w.jav  a  2  s  .c  o  m*/
 *     Nicolas Roduit - initial API and implementation
 *******************************************************************************/

import java.text.Normalizer;

import java.util.regex.Pattern;

public class Main {
    /**
     * Removing diacritical marks aka accents
     * 
     * @param str
     * @return the input string without accents
     */
    public static String deAccent(String str) {
        String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
        Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$
        return pattern.matcher(nfdNormalizedString).replaceAll(""); //$NON-NLS-1$
    }
}

Related

  1. compareIgnoreCaseAndAccent(String string1, String string2, Locale locale)
  2. deAccent(final @Nonnull String string)
  3. deAccent(String str)
  4. deAccent(String str)
  5. deleteAccents(String text)
  6. equalsIgnoreAccents(String lhs, String rhs, Locale locale)
  7. equalsIgnoreAccentsAndCase(String s1, String s2)
  8. equalsIgnoreCaseAndAccent(String string1, String string2, Locale locale)