zeroclickinfo-goodies/lib/DDG/Goodie/IDN.pm

28 lines
579 B
Perl
Raw Normal View History

2012-06-07 14:07:50 -07:00
package DDG::Goodie::IDN;
# ABSTRACT: Convert domain names from/to Punycode.
use DDG::Goodie;
use Net::IDN::Encode ':all';
use HTML::Entities;
2012-07-05 23:06:30 -07:00
attribution web => ['http://7bits.nl/','Peter van Dijk'],
email => ['peter@7bits.nl','Peter van Dijk'],
github => ['habbie'],
twitter => ['habbie'];
2012-06-07 14:07:50 -07:00
triggers start => 'idn';
handle remainder => sub {
if(/^xn--/) {
return 'decoded IDN: '.encode_entities(domain_to_unicode($_));
}
else {
return 'encoded IDN: '.encode_entities(domain_to_ascii($_));
}
# return;
};
zci is_cached => 1;
2012-07-05 23:06:30 -07:00
1;