Net::LibIDN − Perl bindings for GNU Libidn


  use Net::LibIDN ':all';
  idn_to_ascii("Raeksmoergaas.Josefsson.ORG") eq
  idn_prep_name("LibUeDN") eq "libuedn";
  idn_punycode_encode("kistenmoehre") eq
  my $errpos;
  tld_check("", $errpos) eq undef;
    $errpos == 1;
  tld_get("mainbase.mars") eq "mars";
  my $hashref = Net::LibIDN::tld_get_table("de");
  print "$hashref−>{version}\n";
  foreach (@{$hashref−>{valid}})
    print "Unicode range from ".$_−>{start}." to ".$_−>{end}."\n";


Provides bindings for GNU Libidn, a C library for handling Internationalized Domain Names according to IDNA ( RFC 3490), in a way very much inspired by Turbo Fredriksson’s PHP-IDN.

($clear_hostname, [$charset, [$flags]]);

Converts $clear_hostname which might contain characters outside the range allowed in DNS names, to IDNA ACE . If $charset is specified, treats string as being encoded in it, otherwise assumes it is ISO−8859−1 encoded. If flag IDNA_ALLOW_UNASSIGNED is set in $flags, accepts also unassigned Unicode characters, if IDNA_USE_STD3_ASCII_RULES is set, accepts only ASCII LDH characters (letter-digit-hyphen). Flags can be combined with ||. Returns result of conversion or undef on error.

Net::LibIDN::idn_to_unicode($idn_hostname, [$charset, [$flags]]);

Converts ASCII $idn_hostname, which might be IDNA ACE encoded, into the decoded form in $charset or ISO−8859−1 . Flags are interpreted as above. Returns result of conversion or undef on error.

Net::LibIDN::idn_punycode_encode($string, [$charset]);

Encodes $string into "punycode" ( RFC 3492). If $charset is present, treats $string as being in $charset, otherwise uses ISO−8859−1 . Returns result of conversion or undef on error.

Net::LibIDN::idn_punycode_decode($string, [$charset]);

Decodes $string from "punycode" ( RFC 3492). If $charset is present, result is converted to $charset, otherwise it is converted to ISO−8859−1 . Returns result of conversion or undef on error.

Net::LibIDN::idn_prep_name($string, [$charset]);
($string, [$charset]);
($string, [$charset]);
($string, [$charset]);
($string, [$charset]);
($string, [$charset]);
($string, [$charset]);
($string, [$charset]);

Performs "stringprep" ( RFC 3454) on $string according to the named profile (e.g. *_name −> "nameprep" ( RFC 3491)). If $charset is present, converts from and to this charset before and after the operation respectively. Returns result string, or undef on error.

Net::LibIDN::tdl_check($string, $errpos, [$charset, [$tld]]);

Checks whether or not $string conforms to the restrictions on the sets of valid characters defined by TLD authorities around the World. Treats $string as a hostname if $tld is not present, determining the TLD from the hostname. If $tld is present, uses the restrictions defined by the parties responsible for TLD $tld. $charset may be used to specify the character set the $string is in. Should an invalid character be detected, returns 0 and the 0−based position of the offending character in $errpos. In case of other failure conditions, $errpos is not touched, and undef is returned. Should $string conform to the TLD restrictions, 1 is returned.


Returns top level domain of $hostname, or undef if an error occurs or if no top level domain was found.


Retrieves a hash reference with the TLD restriction info of given TLD $tld, or undef if $tld is not found. The hash ref contains the following fields:

$h−>{name} ... name of TLD

$h−>{version} ... version string of this restriction table

$h−>{nvalid} ... number of Unicode intervals

$h−>{valid} ... [ {start => number, end => number}, ...] ... Unicode intervals

There is currently no support for Perl’s unicode capabilities (man perlunicode). All input strings are assumed to be octet strings, all output strings are generated as octet strings. Thus, if you require Perl’s unicode features, you will have to convert your strings manually. For example:

use Encode;

use Data::Dumper;

print Dumper(Net::LibIDN::idn_to_unicode(’xn--uro−’, ’utf−8’));

print Dumper(decode(’utf−8’, Net::LibIDN::idn_to_unicode(’xn--uro−’, ’utf−8’)));


Thomas Jacob,


perl(1), RFC 3454, RFC 3490−3492,


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.