NAME
Unicode::ICU::IDN - Internationalized Domain Names (IDNs) via ICU
SYNOPSIS
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');
DESCRIPTION
This module exposes simple IDN (i.e., Internationalized Domain Name) ASCII/Unicode (punycode) converters.
ERROR HANDLING: INVALID IDNs
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.
COMPATIBILITY
This require ICU 4.6 or later.
SEE ALSO
CONSTANTS
Constructor options
See below.
%ERROR
Correlates IDN error names with error numbers. These derive from ICU’s UIDNA_ERROR_*
constants.
STATIC FUNCTIONS
@labels = get_error_labels( $ERROR_NUMBER )
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.
METHODS
$obj = CLASS->new( [$OPTIONS] )
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.)