Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert IDN to ASCII?

Tags:

c#

.net

idn

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.

like image 733
Espo Avatar asked May 12 '09 11:05

Espo


People also ask

What is IDN encoding?

Internationalised Domain Names (IDNs) is the term used for Internet domain names written using local languages and scripts. All characters which are not one of the 26 letters of the English alphabet, the numbers 0-9 or a hyphen (minus sign) are treated as IDN characters.

What is IDN and Punycode conversion?

IDN domains, unlike regular domains, are encoded using a special encoding scheme called Punycode. Punycode converts the non-English-language characters into a series of letters that stand in for the non-English character. You can recognize an IDN domain in its raw form because you'll see an "xn--" in front of it.

Is IDN domain please convert to Punycode first?

When you wish to register an IDN, you first must encode it using the Punycode system and then register that encoded version. When the user enters the URL in its browser bar containing IDN, the browser first converts the IDN into Punycode and then resolves the domain.

What is a Punycode URL?

What is Punycode? Punycode. noun. Unicode that converts words that cannot be written in ASCII, like the Greek word for thank you 'ευχαριστώ' into an ASCII encoding, like 'xn--mxahn5algcq2e' for use as domain names.


3 Answers

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

like image 102
Abdul Saboor Avatar answered Oct 17 '22 00:10

Abdul Saboor


using System.Globalization;
...
IdnMapping idn = new IdnMapping();
MessageBox.Show(idn.GetAscii("www.kraków.pl"));
like image 28
adam Avatar answered Oct 17 '22 00:10

adam


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

like image 4
dommer Avatar answered Oct 16 '22 22:10

dommer