Skip to content

Instantly share code, notes, and snippets.

@portal7
Created May 26, 2014 20:13
Show Gist options
  • Save portal7/8cdf95743077b7204ab1 to your computer and use it in GitHub Desktop.
Save portal7/8cdf95743077b7204ab1 to your computer and use it in GitHub Desktop.
Normalizacion de Caracteres
static string RemoveDiacritics(string text)
{
var normalizedString = text.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder();
foreach (var c in normalizedString)
{
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment