Net::IDN::Encode(3pm) | User Contributed Perl Documentation | Net::IDN::Encode(3pm) |
Net::IDN::Encode - Internationalizing Domain Names in Applications (IDNA)
use Net::IDN::Encode ':all'; my $a = domain_to_ascii("mueller.example.org"); my $e = email_to_ascii("POSTMASTER@XXXXX"); my $u = domain_to_unicode('EXAMPLE.XN--11B5BS3A9AJ6G');
This module provides an easy-to-use interface for encoding and decoding Internationalized Domain Names (IDNs).
IDNs use characters drawn from a large repertoire (Unicode), but IDNA allows the non-ASCII characters to be represented using only the ASCII characters already allowed in so-called host names today (letter-digit-hyphen, "/[A-Z0-9-]/i").
Use this module if you just want to convert domain names (or email addresses), using whatever IDNA standard is the best choice at the moment.
You should be familiar with Unicode support in perl, as this module expects correctly encoded input. See perlunitut, perluniintro and perlunicode for details.
To convert labels correctly between Unicode and ASCII, each character in the label must be present in the Unicode version supported by your perl. Consequently, this module will refuse to convert labels with new Unicode characters on older perl versions (see below).
By default, this module does not export any subroutines. You may use the ":all" tag to import everything. You can also use regular expressions such as "/^to_/" or "/^email_/" to select some of the functions, see Exporter for details.
The following functions are available:
This function takes the following optional parameters (%param):
While this increases the number of labels that can be converted successfully (especially on older perls) and may thus maximizes the compatibility with domain names created under future versions of Unicode, it also introduces the risk of incorrect conversions. Characters added in later versions of Unicode might have properties that affect the conversion; if these properties are not known on your version of perl, you might therefore end up with an incorrect conversion.
The default is false.
Please note that UseSTD3ASCIIRules only affects the conversion between ASCII labels (A-labels) and Unicode labels (U-labels). Labels that are in ASCII may still be passed-through as-is.
For historical reasons, the default is false (unlike "domain_to_ascii").
The default is false.
This function does not handle strings that consist of multiple labels (such as domain names). Use "domain_to_ascii" instead.
This function takes the same optional parameters as "to_ascii", with the same defaults.
If $label is already in ASCII, this function will never fail but return $label as is as a last resort (i.e. pass-through).
This function takes the following optional parameters (%param):
This function does not handle strings that consist of multiple labels (such as domain names). Use "domain_to_unicode" instead.
This function takes the following optional parameters (%param):
The default is true (unlike "to_ascii").
This function will convert all dots to ASCII, i.e. to U+002E (full stop). The following characters are recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop).
This function takes the same optional parameters as "domain_to_ascii", with the same defaults.
This function takes the following optional parameters (%param):
This function will preserve the original version of dots. The following characters are recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop).
It takes the same parameters as "domain_to_ascii".
This function currently does not handle internationalization of the local-part (left hand side). Future versions of this module might implement an ASCII conversion for the local-part, should one be standardized.
This function will convert the at sign to ASCII, i.e. to U+0040 (commercial at), as well as label separators. The following characters are recognized as at signs: U+0040 (commercial at), U+FE6B (small commercial at) and U+FF20 (fullwidth commercial at).
It takes the same parameters as "domain_to_unicode".
This function currently does not handle internationalization of the local-part (left hand side). Future versions of this module might implement a conversion from ASCII for the local-part, should one be standardized.
This function will preserve the original version of at signs (and label separators). The following characters are recognized as at signs: U+0040 (commercial at), U+FE6B (small commercial at) and U+FF20 (fullwidth commercial at).
Claus Faerber <CFAERBER@cpan.org>
Copyright 2007-2014 Claus Faerber.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Net::IDN::Punycode, Net::IDN::UTS46, Net::IDN::IDNA2003, Net::IDN::IDNA2008, UTS #46 (<http://www.unicode.org/reports/tr46/>), RFC 5890 (<http://tools.ietf.org/html/rfc5890>).
2022-10-19 | perl v5.36.0 |