Unicode::ICU::IDN - Internationalized Domain Names (IDNs) via ICU
use utf8; my $idn = Unicode::ICU::IDN->new(); # This takes a *character* string! my $ascii = $idn->name2ascii('épée.com'); # This outputs a character string. my $unicode = $idn->name2unicode('xn--kxawhkp.gr');
This module exposes simple IDN (i.e., Internationalized Domain Name) ASCII/Unicode (punycode) converters.
In addition to the usual Unicode::ICU::X::ICU errors, this module also throws Unicode::ICU::X::BadIDN errors if a bad IDN is detected. If you want to tolerate bad IDNs you’ll need to convert invalid sequences yourself beforehand.
This require ICU 4.6 or later.
Net::LibIDN2
Net::IDN::UTS46
See below.
Correlates IDN error names with error numbers. These derive from ICU’s UIDNA_ERROR_* constants.
UIDNA_ERROR_*
A convenient function that returns a list of names (e.g., DISALLOWED) from %ERROR that $ERROR_NUMBER indicates. In scalar context this returns the number of such names that would be returned in list context.
DISALLOWED
%ERROR
Instantiates this class. $OPTIONS, if given, is a numeric mask of this module’s UIDNA_* constants: UIDNA_DEFAULT, etc. (See IDN’s API documentation for others.)
UIDNA_*
UIDNA_DEFAULT
To install Unicode::ICU, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Unicode::ICU
CPAN shell
perl -MCPAN -e shell install Unicode::ICU
For more information on module installation, please visit the detailed CPAN module installation guide.