Ruby convert IDN domain from Punycode to Unicode

后端 未结 4 1971
北海茫月
北海茫月 2021-01-05 06:53

I\'m writing a Rails app that needs to convert an IDN domain name from Punycode into its Unicode equivalent. I tried installing the idn gem that has bindings to GNU LibIDN,

4条回答
  •  甜味超标
    2021-01-05 07:08

    https://github.com/knu/ruby-domain_name seem to have exactly the same functionality:

    irb(main):018:0> SimpleIDN::Punycode.encode('axa.test')
    => "axa.test-"
    
    irb(main):017:0> DomainName::Punycode.encode('axa.test')
    => "axa.test-"
    

提交回复
热议问题