Menu

#5 Support for internationalized domain names (IDN)

open
nobody
None
5
2004-09-17
2004-09-17
No

I noticed that LWP::UserAgent doesn't work for URLs
such as http://www.bücher.de/ . I found that one way of
getting around that problem is by creating a subclass:

package LWP::UserAgent::IDN;

use base 'LWP::UserAgent';
use Net::IDN::Encode;

sub prepare_request {
my ($self, $request) = @_;
my $uri = $request->uri;
eval {
my $host = domain_to_ascii($uri->host);
$uri->host($host);
};
$request;
}

1;
__END__

Note that this requires the Net::IDN::Encode module and
its dependencies (including Unicode::String). There are
at least two other modules which could be used instead
of Net::IDN::Encode, but I tried this one and it works.

Perhaps a future version of the distribution could
include support for IDNs?

--
Ivan

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.