The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Template::Plugin::Filter::IDN - Template Toolkit plugin for encoding and decoding International Domain Names.

VERSION

version 0.04

SYNOPSIS

 #
 # Convert a UTF-8 domain name to Punycode:
 #
 [%- USE Filter.IDN -%]
 <a href="http://[% '域名.org' | idn('to_ascii') %]">Link</a>

 # Output
 <a href="http://xn--eqrt2g.org">Link</a>

 #
 # Convert Punycode to UTF-8:
 #
 [%- USE Filter.IDN -%]
 [% 'xn--eqrt2g.org' | idn('to_utf8') %]

 # Output:
 域名.org

DESCRIPTION

This is a Template Toolkit filter which handles conversion of International Domain Names from UTF-8 to ASCII (in Punycode encoding) and vice versa.

USAGE

Include [% USE Filter.IDN %] in your template. Then you will be able to use the idn filter to encode or decode International Domain Names. The filter takes a single required argument which is the action that is requested. The must be one of the following values:

  • to_ascii

    Convert a UTF-8 label to Punycode. If the string is already an ASCII string, the original string will be passed through the filter.

  • encode

    This is an alias for to_ascii. Think "encode" to Punycode.

  • to_utf8

    Convert a Punycode label to UTF-8. If the string is not a Punycode string, then the original string will be passed through the filter.

  • decode

    This is an alias for to_utf8. Think "decode" from Punycode.

SEE ALSO

Net::IDN::Encode

SOURCE

The development version is on github at http://https://github.com/mschout/perl-template-plugin-filter-idn and may be cloned from git://https://github.com/mschout/perl-template-plugin-filter-idn.git

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/mschout/perl-template-plugin-filter-idn/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Michael Schout <mschout@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Michael Schout.

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