Bỏ dấu tiếng việt
static string ConvertCombiningDiacriticsToPrecomposed(string input)
{
string normalized = input.Normalize(NormalizationForm.FormD);
StringBuilder precomposed = new StringBuilder();
foreach (char c in normalized)
{
UnicodeCategory category = CharUnicodeInfo.GetUnicodeCategory(c);
if (category != UnicodeCategory.NonSpacingMark)
{
precomposed.Append(c);
}
}
return precomposed.ToString().Normalize(NormalizationForm.FormC);
}
static string ConvertCombiningDiacriticsToPrecomposedWithoutRemovingDiacritics(string input)
{
return input.Normalize(NormalizationForm.FormC);
}
Comments
Post a Comment