Skip to content

Instantly share code, notes, and snippets.

@toburger
Created January 10, 2014 11:25
Show Gist options
  • Save toburger/8350392 to your computer and use it in GitHub Desktop.
Save toburger/8350392 to your computer and use it in GitHub Desktop.
/// <summary>Removes Diacritics (tilde, cédille, umlaut and friends) from String</summary>
public static string RemoveDiacritics(this string s)
{
string normalizedString = s.Normalize(NormalizationForm.FormD);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < normalizedString.Length; i++)
{
char c = normalizedString[i];
if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
stringBuilder.Append(c);
}
return stringBuilder.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment