LibIDN(3)
okay so bestie, this is LibIDN(3) — from the User Contributed Perl Documentation shelf — and it’s giving “Perl bindings for GNU Libidn” energy 💖 like, the whole page is about Net::LibIDN, no cap.
💖 NAME 💖
Net::LibIDN — Perl bindings for GNU Libidn
✨ SYNOPSIS ✨
use Net::LibIDN ':all';
idn_to_ascii("Räksmörgås.Josefßon.ORG") eq
idn_to_ascii(idn_to_unicode("xn--rksmrgs-5wao1o.josefsson.org"));
idn_prep_name("LibÜDN") eq "libüdn";
idn_punycode_encode("kistenmöhre") eq
idn_punycode_encode(idn_punycode_decode("kistenmhre-kcb"));
my $errpos;
tld_check("mèrle.se", $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";
}
💅 DESCRIPTION 💅
Okay so Net::LibIDN 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. Slay. 💅
🧚 Functions 🧚
Net::LibIDN::idn_to_ascii($clear_hostname, [$charset, [$flags]]);— Converts$clear_hostname, which might contain characters outside the range allowed in DNS names, to IDNA ACE. If$charsetis specified, treats the string as being encoded in it; otherwise assumes it isISO-8859-1encoded. If flagIDNA_ALLOW_UNASSIGNEDis set in$flags, accepts also unassigned Unicode characters; ifIDNA_USE_STD3_ASCII_RULESis set, accepts only ASCII LDH characters (letter-digit-hyphen). Flags can be combined with||. Returns result of conversion orundefon 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$charsetorISO-8859-1. Flags are interpreted as above. Returns result of conversion orundefon error.Net::LibIDN::idn_punycode_encode($string, [$charset]);— Encodes$stringinto "punycode" (RFC 3492). If$charsetis present, treats$stringas being in$charset; otherwise usesISO-8859-1. Returns result of conversion orundefon error.Net::LibIDN::idn_punycode_decode($string, [$charset]);— Decodes$stringfrom "punycode" (RFC 3492). If$charsetis present, result is converted to$charset; otherwise it is converted toISO-8859-1. Returns result of conversion orundefon error.
These next ones are the stringprep squad, and they all share one whole vibe:
Net::LibIDN::idn_prep_name($string, [$charset]);Net::LibIDN::idn_prep_kerberos5($string, [$charset]);Net::LibIDN::idn_prep_node($string, [$charset]);Net::LibIDN::idn_prep_resource($string, [$charset]);Net::LibIDN::idn_prep_plain($string, [$charset]);Net::LibIDN::idn_prep_trace($string, [$charset]);Net::LibIDN::idn_prep_sasl($string, [$charset]);Net::LibIDN::idn_prep_iscsi($string, [$charset]);
All of these perform "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$stringconforms to the restrictions on the sets of valid characters defined by TLD authorities around the World. Treats$stringas a hostname if$tldis not present, determining the TLD from the hostname. If$tldis present, uses the restrictions defined by the parties responsible for TLD$tld.$charsetmay be used to specify the character set the$stringis in. Should an invalid character be detected, returns0and the 0-based position of the offending character in$errpos. In case of other failure conditions,$errposis not touched, andundefis returned. Should$stringconform to the TLD restrictions,1is returned.Net::LibIDN::tld_get($hostname);— Returns top level domain of$hostname, orundefif an error occurs or if no top level domain was found.Net::LibIDN::tld_get_table($tld);— Retrieves a hash reference with the TLD restriction info of given TLD$tld, orundefif$tldis 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
🌀 Limitations 🌀
real talk bestie, this is the caveat part 🫶
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-j50a.com',
'utf-8'));
print Dumper(decode('utf-8',
Net::LibIDN::idn_to_unicode('xn--uro-j50a.com', 'utf-8')));
👑 AUTHOR 👑
Thomas Jacob, http://internet24.de
🌈 SEE ALSO 🌈
perl(1), RFC 3454, RFC 3490-3492, http://www.gnu.org/software/libidn.
mwah 💋 that’s the whole vibe. This page came from perl v5.42.0, dated 2010-11-30, and it’s LibIDN(3) — go forth and IDN responsibly, bestie 🫶✨
📦 where this page comes from
- opensuse-leap 16.0: perl-Net-LibIDN 0.12-bp160.1.13 · GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Net-LibIDN 0.12-bp160.1.13 · GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Net-LibIDN 0.12-bp160.1.13 · GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Net-LibIDN 0.12-bp160.1.13 · GPL-1.0+ or Artistic-1.0
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms