May 09 2011 18:00 CET
Dealing with IDN can be bit of a hazzle. Luckily the
libidn project makes it very easy.
At DNSapp.net I use the Ruby bindings provided in the ruby gem
idn to convert from unicode domain strings to so-called ACE strings and visa versa.
However, the gem breaks with Ruby 1.9.2 and an update doesn’t seem to be available any time soon.
So, a few days ago I took it upon myself to try to create a pure ruby implementation that could replace the current
idn gem. Besides giving me a better understanding of the, not quite obvious conversion that goes on in punycode, it would also mean that I wouldn’t need the
libidn package when setting up application servers.
I’ve just released the gem which works for both Ruby 1.8.7 and 1.9.2. So now you should be able to do something like this:
require 'rubygems' require 'simpleidn' SimpleIDN.to_unicode "xn--mllerriis-l8a.com" SimpleIDN.to_ascii "møllerriis.com"
Btw. taking care of proper encoding across Ruby 1.8/1.9 is quite a hassle! I think I will return with a post on the encoding issue at some point.