Tuesday, June 24, 2008

Punycode in VB.NET for IDN domains

On one of my web sites I noticed that IDN (Internationalized Domain Names) don't work when I do Response.Redirect in VB.NET.

IDNs are used to allow accented and other special international characters (non-Ascii) to be used in domain names. Since Domain Name Servers (DNS) only support Ascii, any IDN is encoded in Punycode.


To encode a string as Punycode in VB.NET simply do this:


Dim strUrl As String = "http://idn-example-åäö.com"
Dim idn As System.Globalization.IdnMapping = New System.Globalization.IdnMapping
strUrl = idn.GetAscii(strUrl)

Labels: , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home