diff --git a/dist.ini b/dist.ini index a6fd5b539..6e43518cd 100644 --- a/dist.ini +++ b/dist.ini @@ -29,6 +29,7 @@ Convert::Color = 0.08 Convert::Color::Library = 0.03 Math::Round = 0.06 Convert::Morse = 0.05 +Net::IDN::Encode = 2.003 [Prereqs / TestRequires] Test::More = 0.98 diff --git a/lib/DDG/Goodie/IDN.pm b/lib/DDG/Goodie/IDN.pm new file mode 100644 index 000000000..593af734c --- /dev/null +++ b/lib/DDG/Goodie/IDN.pm @@ -0,0 +1,22 @@ +package DDG::Goodie::IDN; +# ABSTRACT: Convert domain names from/to Punycode. + +use DDG::Goodie; +use Net::IDN::Encode ':all'; +use HTML::Entities; + +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; + +1; \ No newline at end of file