Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 04, 2011 01:21 PM by XIII
Member
27 Points
11 Posts
Apr 04, 2011 12:57 PM|LINK
Hello, I would like to convert in the ASP.NET MVC C# the chars like:
ěščřžýáíéúüů
into
escrzyaieuuu and then use this text in the url. Please help me with this problem and show me any easy solution. Thanks for help!
All-Star
23680 Points
4051 Posts
Apr 04, 2011 01:17 PM|LINK
Try this
private static string normalizeString(string s) { string n = s.Normalize(NormalizationForm.FormD); StringBuilder sb = new StringBuilder(n); for (int i = 0; i < sb.Length; i++) { if (CharUnicodeInfo.GetUnicodeCategory(sb[i]) == UnicodeCategory.NonSpacingMark) sb.Remove(i, 1); } return sb.ToString(); }
182702 Points
23463 Posts
ASPInsiders
Moderator
MVP
Apr 04, 2011 01:21 PM|LINK
Hi,
what you're after is how to strip diacritic characters. Here's a possible solution: http://blogs.msdn.com/b/michkap/archive/2005/02/19/376617.aspx. Be sure to also check out the upgraded code in http://blogs.msdn.com/b/michkap/archive/2005/02/19/376617.aspx.
Grz, Kris.
jan.nemec
Member
27 Points
11 Posts
Convert national chars into standard chars in ASP.NET MVC C#
Apr 04, 2011 12:57 PM|LINK
Hello,
I would like to convert in the ASP.NET MVC C# the chars like:
ěščřžýáíéúüů
into
escrzyaieuuu and then use this text in the url.
Please help me with this problem and show me any easy solution.
Thanks for help!
smirnov
All-Star
23680 Points
4051 Posts
Re: Convert national chars into standard chars in ASP.NET MVC C#
Apr 04, 2011 01:17 PM|LINK
Try this
private static string normalizeString(string s) { string n = s.Normalize(NormalizationForm.FormD); StringBuilder sb = new StringBuilder(n); for (int i = 0; i < sb.Length; i++) { if (CharUnicodeInfo.GetUnicodeCategory(sb[i]) == UnicodeCategory.NonSpacingMark) sb.Remove(i, 1); } return sb.ToString(); }XIII
All-Star
182702 Points
23463 Posts
ASPInsiders
Moderator
MVP
Re: Convert national chars into standard chars in ASP.NET MVC C#
Apr 04, 2011 01:21 PM|LINK
Hi,
what you're after is how to strip diacritic characters. Here's a possible solution: http://blogs.msdn.com/b/michkap/archive/2005/02/19/376617.aspx. Be sure to also check out the upgraded code in http://blogs.msdn.com/b/michkap/archive/2005/02/19/376617.aspx.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!