The manakai project

Web::DomainName::Punycode

A wrapper for Punycode encoding and decoding

SYNOPSIS

  use Web::DomainName::Punycode;
  $out = encode_punycode $in;
  $out = decode_punycode $in;

DESCRIPTION

The Web::DomainName::Punycode module provides functions to encode and decode Punycode.

FUNCTIONS

This module exports two functions:

$out = encode_punycode $in

Encode the given string. It returns the Punycode-encoded representation, i.e. a string of ASCII characters. If the input cannot be encoded, undef is returned.

$out = decode_punycode $in

Decode the given string. It returns the Punycode-decoded representation, i.e. a string of Unicode characters. If the input cannot be decoded, e.g. because the input is not a Punycode-encoded string, undef is returned.

SEE ALSO

RFC 3492, Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA), March 2003. <https://tools.ietf.org/html/rfc3492>.

SuikaWiki:Punycode <https://suika.suikawiki.org/~wakaba/wiki/sw/n/Punycode>.

Although there are a number of Punycode implementations written in Perl, they are broken or badly designed (see "Implementation" section of <https://suika.suikawiki.org/~wakaba/wiki/sw/n/Punycode>). Relatively better implementations of Punycode include:

Net::LibIDN. GNU IDN Library - Libidn <http://www.gnu.org/s/libidn/>.

URI::_punycode.

Previous version of the Web::DomainName::Punycode depend on one of these modules. However, for the ease of deployment, current version of the module contains a copy of URI::_punycode such that no XS or Perl module is required for encoding and decoding.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

ACKNOWLEDGEMENTS

This module contains a copy of URI::_punycode, whose credit contains:

  Tatsuhiko Miyagawa <miyagawa@bulknews.net> is the author of
  IDNA::Punycode v0.02 which was the basis for this module.

LICENSE

Copyright 2011-2012 Wakaba <wakaba@suikawiki.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.