1LibIDN(3)             User Contributed Perl Documentation            LibIDN(3)
2
3
4

NAME

6       Net::LibIDN - Perl bindings for GNU Libidn
7

SYNOPSIS

9         use Net::LibIDN ':all';
10
11         idn_to_ascii("Räksmörgås.Josefßon.ORG") eq
12           idn_to_ascii(idn_to_unicode("xn--rksmrgs-5wao1o.josefsson.org"));
13
14         idn_prep_name("LibÜDN") eq "libüdn";
15
16         idn_punycode_encode("kistenmöhre") eq
17           idn_punycode_encode(idn_punycode_decode("kistenmhre-kcb"));
18
19         my $errpos;
20         tld_check("mèrle.se", $errpos) eq undef;
21           $errpos == 1;
22
23         tld_get("mainbase.mars") eq "mars";
24
25         my $hashref = Net::LibIDN::tld_get_table("de");
26
27         print "$hashref->{version}\n";
28         foreach (@{$hashref->{valid}})
29         {
30           print "Unicode range from ".$_->{start}." to ".$_->{end}."\n";
31         }
32

DESCRIPTION

34       Provides bindings for GNU Libidn, a C library for handling Internation‐
35       alized Domain Names according to IDNA (RFC 3490), in a way very much
36       inspired by Turbo Fredriksson's PHP-IDN.
37
38       Functions
39
40       Net::LibIDN::idn_to_ascii($clear_hostname, [$charset, [$flags]]);
41           Converts $clear_hostname which might contain characters outside the
42           range allowed in DNS names, to IDNA ACE. If $charset is specified,
43           treats string as being encoded in it, otherwise assumes it is
44           ISO-8859-1 encoded. If flag IDNA_ALLOW_UNASSIGNED is set in $flags,
45           accepts also unassigned Unicode characters, if
46           IDNA_USE_STD3_ASCII_RULES is set, accepts only ASCII LDH characters
47           (letter-digit-hyphen). Flags can be combined with ⎪⎪. Returns
48           result of conversion or undef on error.
49
50       Net::LibIDN::idn_to_unicode($idn_hostname, [$charset, [$flags]]);
51           Converts ASCII $idn_hostname, which might be IDNA ACE encoded, into
52           the decoded form in $charset or ISO-8859-1. Flags are interpreted
53           as above. Returns result of conversion or undef on error.
54
55       Net::LibIDN::idn_punycode_encode($string, [$charset]);
56           Encodes $string into "punycode" (RFC 3492). If $charset is present,
57           treats $string as being in $charset, otherwise uses ISO-8859-1.
58           Returns result of conversion or undef on error.
59
60       Net::LibIDN::idn_punycode_decode($string, [$charset]);
61           Decodes $string from "punycode" (RFC 3492). If $charset is present,
62           result is converted to $charset, otherwise it is converted to
63           ISO-8859-1. Returns result of conversion or undef on error.
64
65       Net::LibIDN::idn_prep_name($string, [$charset]);
66       Net::LibIDN::idn_prep_kerberos5($string, [$charset]);
67       Net::LibIDN::idn_prep_node($string, [$charset]);
68       Net::LibIDN::idn_prep_resource($string, [$charset]);
69       Net::LibIDN::idn_prep_plain($string, [$charset]);
70       Net::LibIDN::idn_prep_trace($string, [$charset]);
71       Net::LibIDN::idn_prep_sasl($string, [$charset]);
72       Net::LibIDN::idn_prep_iscsi($string, [$charset]);
73           Performs "stringprep" (RFC 3454) on $string according to the named
74           profile (e.g. *_name -> "nameprep" (RFC 3491)).  If $charset is
75           present, converts from and to this charset before and after the
76           operation respectively. Returns result string, or undef on error.
77
78       Net::LibIDN::tdl_check($string, $errpos, [$charset, [$tld]]);
79           Checks whether or not $string conforms to the restrictions on the
80           sets of valid characters defined by TLD authorities around the
81           World. Treats $string as a hostname if $tld is not present, deter‐
82           mining the TLD from the hostname. If $tld is present, uses the
83           restrictions defined by the parties responsible for TLD $tld.
84           $charset may be used to specify the character set the $string is
85           in. Should an invalid character be detected, returns 0 and the
86           0-based position of the offending character in $errpos. In case of
87           other failure conditions, $errpos is not touched, and undef is
88           returned. Should $string conform to the TLD restrictions, 1 is
89           returned.
90
91       Net::LibIDN::tld_get($hostname);
92           Returns top level domain of $hostname, or undef if an error occurs
93           or if no top level domain was found.
94
95       Net::LibIDN::tld_get_table($tld);
96           Retrieves a hash reference with the TLD restriction info of given
97           TLD $tld, or undef if $tld is not found. The hash ref contains the
98           following fields:
99
100           * $h->{name} ... name of TLD
101           * $h->{version} ... version string of this restriction table
102           * $h->{nvalid} ... number of Unicode intervals
103           * $h->{valid} ...  [ {start => number, end => number}, ...] ...
104           Unicode intervals
105
106       Limitations
107
108       There is currently no support for Perl's unicode capabilities (man per‐
109       lunicode).  All input strings are assumed to be octet strings, all out‐
110       put strings are generated as octet strings. Thus, if you require Perl's
111       unicode features, you will have to convert your strings manually. For
112       example:
113
114           use Encode;
115
116           use Data::Dumper;
117
118           print Dumper(Net::LibIDN::idn_to_unicode('xn--uro-j50a.com',
119           'utf-8'));
120
121           print Dumper(decode('utf-8', Net::LibIDN::idn_to_uni‐
122           code('xn--uro-j50a.com', 'utf-8')));
123

AUTHOR

125       Thomas Jacob, http://internet24.de
126

SEE ALSO

128       perl(1), RFC 3454, RFC 3490-3492, http://www.gnu.org/software/libidn.
129
130
131
132perl v5.8.8                       2008-02-10                         LibIDN(3)
Impressum