I'm having problem with URL's that include special characters. The rendered HTML if I use NavigateUrl='Eval("website")'
is this:
<a href="http://www.v%c3%a4rnamo.nu">www.värnamo.nu</a>
If I try to encode it like this NavigateUrl='<%# HttpUtility.HtmlEncode(Eval("website")) %>'
I get this output, which doesn't work either.
<a href="http://www.v&/"288;rnamo.nu">www.värnamo.nu</a>
I tried setting charset in the meta tag to UTF-8
and iso-8859-1
, but it didn't help, and I don't think it has to do with that either.
Try clicking this link: http://www.v%c3%a4rnamo.nu and you'll get the same response.
Anything else I can try?
I actually got this to work now. I used the code at this LINK
In my aspx page I use this in the NavigateUrl property:
NavigateUrl='<%# idnMapping(Convert.ToString(Eval("website"))) %>'
Which calls the function:
public static string idnMapping(string text) {
System.Globalization.IdnMapping idn = new System.Globalization.IdnMapping();
return idn.GetAscii(text);
}
Now when I view the html I see
<a href="http://xn--vrnamo-bua.nu">www.värnamo.nu</a>
And clicking this link will open the page correctly.