How to convert IDN to ASCII?

后端 未结 3 713
北海茫月
北海茫月 2020-12-15 09:02

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

I want to convert Bücher.ch into xn--

相关标签:
3条回答
  • 2020-12-15 09:40

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

    0 讨论(0)
  • 2020-12-15 09:42
    using System.Globalization;
    ...
    IdnMapping idn = new IdnMapping();
    MessageBox.Show(idn.GetAscii("www.kraków.pl"));
    
    0 讨论(0)
  • 2020-12-15 09:54

    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

    0 讨论(0)
提交回复
热议问题