Created
January 10, 2014 11:25
-
-
Save toburger/8350392 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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