C# Normalize Internationalized String

//Using Statements using System.Text.RegularExpressions; using System.Text; using System.Globalization; //Method //s: "Ñoño Gómez" //Returns "Nono Gomez" private static string NormalizeString(string s) { string normalized = s.Normalize(NormalizationForm.FormD); var builder = new StringBuilder(); foreach (char ch in normalized) { if (CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark) { builder.Append(ch); } } return builder.ToString().Normalize(NormalizationForm.FormC); }
Converts an internationalized string to a string without accents and weird stuff...

Taken from Stack Overflow, pending to add link and creator.

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.