Here you can find the source of removeAccentuation(String str)
Parameter | Description |
---|---|
str | the string to read from |
str
have been replaced by their unaccentuated equivalent.
public static String removeAccentuation(String str)
//package com.java2s; //License from project: Apache License import java.text.Normalizer; public class Main { /**//from www . ja v a 2s .co m * @param str the string to read from * @return a new string in which all accentuated characters from <code>str</code> have been replaced * by their unaccentuated equivalent. */ public static String removeAccentuation(String str) { // trivial cases (null, empty or simple string) if (str == null || str.isEmpty() || str.matches("[\\w\\s\\.\\,\\;\\:\\!\\?\\+]*")) return str; /** * first split compounded characters into their canonical decomposition, * then, remove all characters that are diacritiques. * * @see http://glaforge.free.fr/weblog/index.php?itemid=115 * @see http://www.unicode.org/fr/charts/PDF/U0300.pdf */ return Normalizer.normalize(str, Normalizer.Form.NFD).replaceAll("[\u0300-\u036f]", ""); } }