Rand Stats

Net::LibIDN2

cpan:KAIEPI

Build Status

NAME

Net::LibIDN2 - Perl 6 bindings for GNU LibIDN2

SYNOPSIS

    use Net::LibIDN2;

    my $idn = Net::LibIDN2.new;

    my Int $code;
    my $ulabel = "m\xFC\xDFli";
    my $alabel = $idn.lookup_u8($ulabel, IDN2_NFC_INPUT, $code);
    say "$alabel $code"; # xn--mli-5ka8l 0

    my $result = $idn.register_u8($ulabel, $alabel, IDN2_NFC_INPUT, $code);
    say "$result $code"; # xn--mli-5ka8l 0
    say $idn.strerror($code);      # success
    say $idn.strerror_name($code); # IDN2_OK

DESCRIPTION

Net::LibIDN2 is a Perl 6 wrapper for the GNU LibIDN2 library.

METHODS

Compares $version against the version of LibIDN2 installed and returns either an empty string if $version is greater than the version installed, or IDN2_VERSION otherwise.

Returns the error represented by $errno in human readable form.

Returns the internal error name of $errno.

Converts a UTF8 encoded string $input to ASCII and returns the output. $code, if provided, is assigned to IDN2_OK on success, or another error code otherwise. Requires LibIDN2 v2.0.0 or greater.

Converts an ACE encoded domain name $input to UTF8 and returns the output. $code, if provided, is assigned to IDN2_OK on success, or another error code otherwise. Requires LibIDN v2.0.0 or greater.

Performs an IDNA2008 lookup string conversion on $input. See RFC 5891, section 5. $input must be a UTF8 encoded string in NFC form if no IDN2_NFC_INPUT flag is passed.

Performs an IDNA2008 register string conversion on $uinput and $ainput. See RFC 5891, section 4. $uinput must be a UTF8 encoded string in NFC form if no IDN2_NFC_INPUT flag is passed. $ainput must be an ACE encoded string.

CONSTANTS

The maximum label length.

The maximum domain name length.

VERSIONING

The version of LibIDN2 installed.

The version of LibIDN2 installed represented as a 32 bit integer. The first pair of bits represents the major version, the second represents the minor version, and the last 4 represent the patch version.

The major version of LibIDN2 installed.

The minor version of LidIDN2 installed.

The patch version of LibIDN2 installed.

FLAGS

Normalize the input string using the NFC format.

Perform optional IDNA2008 lookup roundtrip check.

Perform Unicode TR46 transitional processing.

Perform Unicode TR46 non-transitional processing.

ERRORS

Success.

Memory allocation failure.

Failed to determine a string's encoding.

Failed to transcode a string to UTF8.

Unicode data encoding error.

Failed to normalize a string.

Invalid input to Punycode.

Punycode output buffer is too small.

Punycode conversion would overflow.

Domain is larger than IDN2_DOMAIN_MAX_LENGTH.

Label is larger than IDN2_LABEL_MAX_LENGTH.

Invalid A-label.

Given U-label and A-label do not match.

Invalid combination of flags.

String is not normalized in NFC format.

String has forbidden two hyphens.

String has forbidden start/end hyphen.

String has forbidden leading combining character.

String has disallowed character.

String has forbidden context-j character.

String has context-j character without any rull.

String has forbidden context-o character.

String has context-o character without any rull.

String has forbidden unassigned character.

String has forbidden bi-directional properties.

Label has forbidden dot (TR46).

Label has a character forbidden in transitional mode (TR46).

Label has a character forbidden in non-transitional mode (TR46).

AUTHOR

Ben Davies (kaiepi)

COPYRIGHT AND LICENSE

Copyright 2017 Ben Davies

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.