"MC" wrote:
Is there a string function in .NET that will remove the accent marks from letters? I know that's a slightly vague request... and that I could implement it by table lookup (and will do so unless something's already there). But can it be accomplished by switching a string among "cultures" or something like that?
Hi,
You can remove non spacing characters (and possibly modifier characters)
from the string if you normalize it. This will effectively remove accents
(diacritics) as well.
string normalizedString = regularString.Normalize(NormalizationForm.FormD);
StringBuilder sb = new StringBuilder(normalizedString);
for (int i = 0; i < sb.Length; i++)
{
if (CharUnicodeInfo.GetUnicodeCategory(sb[i]) ==
UnicodeCategory.NonSpacingMark)
sb.Remove(i, 1);
}
regularString = sb.ToString();
--
Happy Coding!
Morten Wennevik [C# MVP]