On Mon, 25 Jul 2005 00:40:55 +0200, Austin Ziegler <halostatue / gmail.com>  
wrote:

> On 7/22/05, Hadmut Danisch <x5 / danisch.de> wrote:
>> any library for ruby to convert domain names from and to
>> IDN?
>
> Not that I know of, but aren't they supposed to just be UTF-8?

No, they are encoded using Punycode:

http://en.wikipedia.org/wiki/Punycode

With a quick search for "ruby punycode", I found:

http://raa.ruby-lang.org/project/punycode4r/

And it seems to work:

Punycode.encode(Iconv.iconv("UCS-4LE", "ISO-8859-15", "b?cher")[0])
=> "bcher-kva"

(From the wikipedia article: "b?cher.ch would be represented as  
xn--bcher-kva.ch in IDNA")

Punycode.encode seems to expect "UCS-4LE" encoded strings.

HTH,
Dominik