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-06 09:26:06 -07:00
|
|
|
attribution web => ['http://7bits.nl/', 'Peter van Dijk'],
|
|
|
|
email => ['peter@7bits.nl', 'Peter van Dijk'],
|
|
|
|
github => ['https://github.com/habbie', 'habbie'],
|
|
|
|
twitter => ['https://twitter.com/habbie', 'habbie'];
|
2012-07-05 23:06:30 -07:00
|
|
|
|
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;
|