NAME
Net::LibIDN2 - Perl bindings for GNU Libidn2
SYNOPSIS
use Net::LibIDN2 ':all';
idn2_lookup_u8("müßli.de") eq 'xn--mli-5ka8l.de';
idn2_register_u8("müßli", "xn--mli-5ka8l") eq 'xn--mli-5ka8l.de';
DESCRIPTION
Provides bindings for GNU Libidn2, a C library for handling internationalized domain names according to IDNA 2008 (RFC 5890, RFC 5891, RFC 5892, RFC 5893)
Functions
- Net::LibIDN2::idn2_lookup_u8($src [, $flags [, $rc]]);
-
Perform IDNA2008 lookup string conversion on domain name $src, as described in section 5 of RFC 5891. Note that the input string must be encoded in UTF-8 and be in Unicode NFC form.
Pass IDN2_NFC_INPUT in $flags to convert input to NFC form before further processing. Pass IDN2_ALABEL_ROUNDTRIP in flags to convert any input A-labels to U-labels and perform additional testing. Multiple flags may be specified by binary or:ing them together, for example IDN2_NFC_INPUT | IDN2_ALABEL_ROUNDTRIP.
On error, returns undef. If a scalar variable is provided in $rc, returns the internal libidn2 C library result code as well.
- Net::LibIDN2::idn2_lookup_ul($src [, $flags [, $rc]]);
-
Similar to function
idn2_lookup_u8
but $src is assumed to be encoded in the locale's default coding system, and will be transcoded to UTF-8 and NFC normalized before returning the result. - Net::LibIDN2::idn2_register_u8($ulabel [, $alabel, [$flags, [$rc]]]);
-
Perform IDNA2008 register string conversion on domain label $ulabel and $alabel, as described in section 4 of RFC 5891. Note that the input ulabel must be encoded in UTF-8 and be in Unicode NFC form.
Pass IDN2_NFC_INPUT in $flags to convert input $ulabel to NFC form before further processing.
It is recommended to supply both $ulabel and $alabel for better error checking, but supplying just one of them will work. Passing in only $alabel is better than only $ulabel. See RFC 5891 section 4 for more information.
On error, returns undef. If a scalar variable is provided in $rc, returns the internal libidn2 C library result code as well.
- Net::LibIDN2::idn2_register_u8($ulabel [, $alabel, [$flags, [$rc]]]);
-
Similar to function
idn2_register_ul
but $ulabel is assumed to be encoded in the locale's default coding system, and will be transcoded to UTF-8 and NFC normalized before returning the result. - Net::LibIDN2::idn2_strerror($rc);
-
Convert internal libidn2 error code $rc to a humanly readable string.
- Net::LibIDN2::idn2_strerror_name($rc);
-
Convert internal libidn2 error code $rc to a string corresponding to internal header file symbols names like IDN2_MALLOC.
- Net::LibIDN2::id2n_check_version([$req_version])
-
Checks that the version of the underlying IDN2 C library is at minimum the one given as a string in $req_version and if that is the case returns the actual version string of the underlying C library or undef if the condition is not met. If no parameter is passed to this function no check is done and only the version string is returned.
See IDN2_VERSION for a suitable $req_version string, it corresponds to the idn2.h C header file version at compile time of this Perl module. Normally these two version numbers match, but if you compiled this Perl module against an older libidn2 and then run it with a newer libidn2 shared library they will be different.
Constants
- IDN2_VERSION
-
Pre-processor symbol with a string that describe the C header file version number at compile time of this Perl module. Used together with idn2_check_version() to verify header file and run-time library consistency.
- IDN2_VERSION_NUMBER
-
Pre-processor symbol with a hexadecimal value describing the C header file version number at compile time of this Perl module. For example, when the header version is 1.2.4711 this symbol will have the value 0x01021267. The last four digits are used to enumerate development snapshots, but for all public releases they will be 0000.
- IDN2_LABEL_MAX_LENGTH
-
Constant specifying the maximum length of a DNS label to 63 characters, as specified in RFC 1034.
- IDN2_DOMAIN_MAX_LENGTH
-
Constant specifying the maximum size of the wire encoding of a DNS domain to 255 characters, as specified in RFC 1034. Note that the usual printed representation of a domain name is limited to 253 characters if it does not end with a period or 254 characters if it ends with a period.
Result codes
- "IDN2_OK" Successful return.
- "IDN2_MALLOC" Memory allocation error.
- "IDN2_NO_CODESET" Could not determine locale string encoding format.
- "IDN2_ICONV_FAIL" Could not transcode locale string to UTF-8.
- "IDN2_ENCODING_ERROR" Unicode data encoding error.
- "IDN2_NFC" Error normalizing string.
- "IDN2_PUNYCODE_BAD_INPUT" Punycode invalid input.
- "IDN2_PUNYCODE_BIG_OUTPUT" Punycode output buffer too small.
- "IDN2_PUNYCODE_OVERFLOW" Punycode conversion would overflow.
- "IDN2_TOO_BIG_DOMAIN" Domain name longer than 255 characters.
- "IDN2_TOO_BIG_LABEL" Domain label longer than 63 characters.
- "IDN2_INVALID_ALABEL" Input A-label is not valid.
- "IDN2_UALABEL_MISMATCH" Input A-label and U-label does not match.
- "IDN2_NOT_NFC" String is not NFC.
- "IDN2_2HYPHEN" String has forbidden two hyphens.
- "IDN2_HYPHEN_STARTEND" String has forbidden starting/ending hyphen.
- "IDN2_LEADING_COMBINING" String has forbidden leading combining character.
- "IDN2_DISALLOWED" String has disallowed character.
- "IDN2_CONTEXTJ" String has forbidden context-j character.
- "IDN2_CONTEXTJ_NO_RULE" String has context-j character with no rull.
- "IDN2_CONTEXTO" String has forbidden context-o character.
- "IDN2_CONTEXTO_NO_RULE" String has context-o character with no rull.
- "IDN2_UNASSIGNED" String has forbidden unassigned character.
- "IDN2_BIDI" String has forbidden bi-directional properties.
AUTHOR
Thomas Jacob, http://internet24.de
SEE ALSO
perl(1), RFC 5890-5893, http://www.gnu.org/software/libidn.