Template::Plugin::Filter::IDN - Template Toolkit plugin for encoding and decoding International Domain Names.
version 0.04
# # 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
This is a Template Toolkit filter which handles conversion of International Domain Names from UTF-8 to ASCII (in Punycode encoding) and vice versa.
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:
[% USE Filter.IDN %]
idn
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.
Net::IDN::Encode
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
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.
Michael Schout <mschout@cpan.org>
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.
To install Template::Plugin::Filter::IDN, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Plugin::Filter::IDN
CPAN shell
perl -MCPAN -e shell install Template::Plugin::Filter::IDN
For more information on module installation, please visit the detailed CPAN module installation guide.