RemoveAccentuation

using System; using System.Text; public static class MyExtensionMethods { public static string RemoveAccentuation(this string text) { if (string.IsNullOrWhiteSpace(text)) { return text; } string normalizedString = text.Normalize(NormalizationForm.FormD); StringBuilder stringBuilder = new StringBuilder(); foreach (char c in normalizedString) { UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c); if (unicodeCategory != UnicodeCategory.NonSpacingMark) { stringBuilder.Append(c); } } return stringBuilder.ToString().Normalize(NormalizationForm.FormC); } }
Remove the accentuation from some given string.
I don't really understand how it works, but I found it at internet and it has been very useful.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.