Re: URI-1.54 and punycode

Gisle Aas <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On Apr 7, 2010, at 10:02 , Роман Николаев wrote:

> Hello. Please help me to use your module URI-1.54. I see for URI::_punycode package, but not understand how to use it.
> I need convert domain names from local to punycode.
> 
> Example: "кофемашина.su" (some_russian_letters.su) to "xn--80aannhnjd8c2b.su"
> 
> I try to:
> 
> use URI;
> my $uri = URI->new("some_russian_letters.su", "http");

The problem here is that this actually set up the 'path' portion of the URL to be the "some_russian_letters.su".  The IDNA stuff only applies to the hostname portion.  An example that works (for me) is:

----------------------------------------%<-------------
#!perl -lw
use utf8;
use URI;
my $u = URI->new("http://кофемашина.su");
print $u->host;
----------------------------------------%<-------------

This prints "xn--80aannhnjd8c2b.su".

--Gisle



> my $a = $uri->canonical;
> or
> my $a = $uri->iri;
> 
> but $a is not punycode encoded string, just standart uri encoding: some %xx%xx%xx%xx....su
> 
> Can You get me example or link to example?
> 
> --
> 
>        Roman V. Nikolaev
> 
> mail:        [email protected]
> icq:         198-364-657
> jabber:      [email protected]
> site:        http://www.rshadow.ru
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.