The fastest way to remove accents from a string (without replace)

The following function will remove accents (diacritic marks) from a string, leaving plain characters. For example, “éléphant” would become “elephant”.

public static string RemoveDiacritics(string value)
{
	return new string(value.Normalize(NormalizationForm.FormD).Where(
		c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark
	).ToArray());
}
This version uses LINQ to remove unwanted characters from the array, so there is no need for a StringBuilder.
Comments