How to convert IDN to ASCII?
Asked Answered
C

3

12

What is the best way to convert an internationalized domain name to its ASCII-form?

I want to convert Bücher.ch into xn--bcher-kva.ch by using some sort of (free) .net code.

Cormick answered 12/5, 2009 at 11:28 Comment(0)
D
4

Have a look at the GNU IDN Library - Libidn. The introduction says that C# libraries are available.

Drenthe answered 12/5, 2009 at 11:34 Comment(2)
-1 for suggesting a 3rd party library when .NET itself is capable of this.Gillman
@Gillman The .NET library does not support all chars. link for example: ß is not supported.Fregoso
S
37
using System.Globalization;
...
IdnMapping idn = new IdnMapping();
MessageBox.Show(idn.GetAscii("www.kraków.pl"));
Squeak answered 4/11, 2010 at 20:45 Comment(0)
B
6

To Get the other way around from xn--bcher-kva.ch domain to Bücher.ch

using System.Globalization;
...
IdnMapping idn = new IdnMapping();
MessageBox.Show(idn.GetUnicode("xn--bcher-kva.ch"));

You will get www.kraków.pl as result. Because i came here to look for this :) hope it is helpful for others as well :)

MSDN

Bounder answered 10/3, 2014 at 9:25 Comment(0)
D
4

Have a look at the GNU IDN Library - Libidn. The introduction says that C# libraries are available.

Drenthe answered 12/5, 2009 at 11:34 Comment(2)
-1 for suggesting a 3rd party library when .NET itself is capable of this.Gillman
@Gillman The .NET library does not support all chars. link for example: ß is not supported.Fregoso

© 2022 - 2024 — McMap. All rights reserved.