Ruby converts IDN domain from Punycode to Unicode

I am writing a Rails application that needs to convert an IDN domain name from Punycode to its Unicode equivalent. I tried installing an idn gem that has bindings to GNU LibIDN, but it will not compile native code. Obviously, others have the same problem with Ruby 1.9.x.

I also tried pure Ruby SimpleIDN gem , but I would prefer something native.

+5
source share
3 answers

Try simpleidn gem . It works with Ruby 1.8.7 and 1.9.2.

Gemfile:

gem 'simpleidn'

:

SimpleIDN.to_unicode("xn--mllerriis-l8a.com")
=> "møllerriis.com"

SimpleIDN.to_ascii("møllerriis.com")
=> "xn--mllerriis-l8a.com"
+11

- , (). 09/2010 , > RubyForge. Gemfile idn:

gem 'idn', '~> 0.0.2', :git => 'git://github.com/mihu/idn'

, - :/

+3

https://github.com/knu/ruby-domain_name  , :

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

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

All Articles