IDN Domain names like:
Have to be converted (punycode based) in order to be use with NSUrl
:
IDN : https://en.wikipedia.org/wiki/Internationalized_domain_name
Punycode : https://en.wikipedia.org/wiki/Punycode
You can use System.Globalization.IdnMapping
to convert your domain names to Punycode
and
this Namespace/Class is available in Xamarin.iOS
and Xamarin.Android
.
var idn = new System.Globalization.IdnMapping ();
var dotnetURI = new System.Uri ("http://δπθ.gr);
Console.WriteLine (dotnetURI.ToString());
NSUrl nsURL = new NSUrl (dotnetURI.Scheme, idn.GetAscii (dotnetURI.DnsSafeHost), dotnetURI.PathAndQuery);
Console.WriteLine (nsURL.ToString());
WebView.LoadRequest(new NSUrlRequest(nsURL));
MSDN IdnMapping.GetAscii
: https://msdn.microsoft.com/en-us/library/system.globalization.idnmapping.getascii(v=vs.110).aspx
Note: System.Uri.IdnHost
which handling punycode conversions is a part of .Net 4.6 and is not currently available in the Xamarin's System
namespace
Ref: https://msdn.microsoft.com/en-us/library/system.uri.idnhost(v=vs.110).aspx