Created
May 26, 2014 20:13
-
-
Save portal7/8cdf95743077b7204ab1 to your computer and use it in GitHub Desktop.
Normalizacion de Caracteres
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
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