~ubuntu-branches/ubuntu/trusty/libnet-idn-encode-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/Net/IDN/Punycode.pm

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2012-07-12 17:22:17 UTC
  • Revision ID: package-import@ubuntu.com-20120712172217-6nx4ozcdgpblzes5
Tags: upstream-2.003
ImportĀ upstreamĀ versionĀ 2.003

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Net::IDN::Punycode;
 
2
 
 
3
use 5.006;
 
4
 
 
5
use strict;
 
6
use utf8;
 
7
use warnings;
 
8
 
 
9
use Exporter;
 
10
 
 
11
our $VERSION = "1.100";
 
12
$VERSION = eval $VERSION;
 
13
 
 
14
our @ISA = qw(Exporter);
 
15
our @EXPORT = ();
 
16
our @EXPORT_OK = ();
 
17
our %EXPORT_TAGS = ( 'all'  => [ qw(encode_punycode decode_punycode) ], );
 
18
Exporter::export_ok_tags(keys %EXPORT_TAGS);
 
19
 
 
20
eval { 
 
21
  require XSLoader;
 
22
  XSLoader::load('Net::IDN::Punycode'); 
 
23
};
 
24
 
 
25
if (!defined(&encode_punycode)) {
 
26
  require Net::IDN::Punycode::PP;
 
27
  Net::IDN::Punycode::PP->import(qw(:all));
 
28
}
 
29
 
 
30
1;
 
31
__END__
 
32
 
 
33
=head1 NAME
 
34
 
 
35
Net::IDN::Punycode - A Bootstring encoding of Unicode for IDNA (S<RFC 3492>)
 
36
 
 
37
=head1 SYNOPSIS
 
38
 
 
39
  use Net::IDN::Punycode qw(:all);
 
40
  $punycode = encode_punycode($unicode);
 
41
  $unicode  = decode_punycode($punycode);
 
42
 
 
43
=head1 DESCRIPTION
 
44
 
 
45
This module implements the Punycode encoding. Punycode is an instance of a more
 
46
general algorithm called Bootstring, which allows strings composed from a small
 
47
set of "basic" code points to uniquely represent any string of code points
 
48
drawn from a larger set. Punycode is Bootstring with particular parameter
 
49
values appropriate for IDNA.
 
50
 
 
51
Note that this module does not do any string preparation as specified by
 
52
I<Nameprep>/I<IDNA2008>/I<PRECIS> and does not add nor remove the ACE prefix
 
53
(C<xn-->). Thus, use L<Net::IDN::Encode> if you want to convert domain names.
 
54
 
 
55
=head1 WARNING
 
56
 
 
57
Usually, it is not a good idea to use this module directly. If you convert
 
58
domain labels (or other strings) without proper prepration, you may end up with
 
59
an ASCII encoding that is not interoperable or even poses security issues due
 
60
to spoofing.
 
61
 
 
62
Even if you think that your domain names are valid and already mapped to the
 
63
correct form, you might be fooled by different Unicode normalization forms (for
 
64
example, some environments might automatically convert your data to NFD, which
 
65
breaks IDNA).
 
66
 
 
67
=head1 FUNCTIONS
 
68
 
 
69
No functions are exported by default. You can use the tag C<:all>
 
70
or import them individually.
 
71
 
 
72
The following functions are available:
 
73
 
 
74
=over
 
75
 
 
76
=item encode_punycode($input)
 
77
 
 
78
Encodes C<$input> with Punycode and returns the result.
 
79
 
 
80
This function will throw an exception on invalid/unencodable input.
 
81
 
 
82
=item decode_punycode($input)
 
83
 
 
84
Decodes C<$input> with Punycode and returns the result.
 
85
 
 
86
This function will throw an exception on invalid input.
 
87
 
 
88
=back
 
89
 
 
90
=head1 AUTHORS
 
91
 
 
92
Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> (versions 0.01 to 0.02)
 
93
 
 
94
Claus FE<auml>rber E<lt>CFAERBER@cpan.orgE<gt> (versions 1.000 and higher)
 
95
 
 
96
=head1 LICENSE
 
97
 
 
98
Copyright 2002-2004 Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
 
99
 
 
100
Copyright 2007-2012 Claus FE<auml>rber E<lt>CFAERBER@cpan.orgE<gt>
 
101
 
 
102
This library is free software; you can redistribute it and/or modify
 
103
it under the same terms as Perl itself.
 
104
 
 
105
=head1 SEE ALSO
 
106
 
 
107
S<RFC 3492> (L<http://www.ietf.org/rfc/rfc3492.txt>),
 
108
L<IETF::ACE>, L<Convert::RACE>
 
109
 
 
110
=cut