Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Removing accents in NET 2.0 with C#

Removing accents in NET 2.0

static string UrlSanitize(string url)
{
	url = Regex.Replace(url, @"\s+", "-");
	string stFormD = url.Normalize(NormalizationForm.FormD);
	StringBuilder sb = new StringBuilder();
 
	for (int ich = 0; ich < stFormD.Length; ich++)
	{
		UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
		if (uc != UnicodeCategory.NonSpacingMark)
		{
			sb.Append(stFormD[ich]);
		}
	}
 
	return (sb.ToString());
}
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS