"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 normalizedStrin g = regularString.N ormalize(Normal izationForm.For mD);
StringBuilder sb = new StringBuilder(n ormalizedString );
for (int i = 0; i < sb.Length; i++)
{
if (CharUnicodeInf o.GetUnicodeCat egory(sb[i]) ==
UnicodeCategory .NonSpacingMark )
sb.Remove(i, 1);
}
regularString = sb.ToString();
--
Happy Coding!
Morten Wennevik [C# MVP]