Skip to content

Instantly share code, notes, and snippets.

@jcracknell
Created July 5, 2013 14:50
Show Gist options
  • Save jcracknell/5935083 to your computer and use it in GitHub Desktop.
Save jcracknell/5935083 to your computer and use it in GitHub Desktop.
public static string RemoveDiacritics(this string str) {
var formD = str.Normalize(NormalizationForm.FormD);
var bp = 0;
var buffer = new char[formD.Length];
for(var i = 0; i < formD.Length; i++)
if(UnicodeCategory.NonSpacingMark != CharUnicodeInfo.GetUnicodeCategory(formD[i]))
buffer[bp++] = formD[i];
return new string(buffer, 0, bp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment