Skip to content

Commit 4fd548d

Browse files
Merge pull request #46 from libwww-perl/genio-puny-doc
Update the documentation for URI::_punycode
2 parents da086d4 + 571967c commit 4fd548d

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Revision history for URI
22

33
{{$NEXT}}
4+
- Update documentation for URI::_punycode (GH Issue #45)
45

56
1.72 2017-07-25
67
- Convert the dist to Dist::Zilla for authoring.

lib/URI/_punycode.pm

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -147,58 +147,72 @@ sub min {
147147
1;
148148
__END__
149149
150+
=encoding utf8
151+
150152
=head1 NAME
151153
152154
URI::_punycode - encodes Unicode string in Punycode
153155
154156
=head1 SYNOPSIS
155157
156-
use URI::_punycode;
157-
$punycode = encode_punycode($unicode);
158-
$unicode = decode_punycode($punycode);
158+
use strict;
159+
use warnings;
160+
use utf8;
159161
160-
=head1 DESCRIPTION
162+
use URI::_punycode qw(encode_punycode decode_punycode);
161163
162-
URI::_punycode is a module to encode / decode Unicode strings into
163-
Punycode, an efficient encoding of Unicode for use with IDNA.
164+
# encode a unicode string
165+
my $punycode = encode_punycode('http://☃.net'); # http://.net-xc8g
166+
$punycode = encode_punycode('bücher'); # bcher-kva
167+
$punycode = encode_punycode('他们为什么不说中文'); # ihqwcrb4cv8a8dqg056pqjye
164168
165-
This module requires Perl 5.6.0 or over to handle UTF8 flagged Unicode
166-
strings.
169+
# decode a punycode string back into a unicode string
170+
my $unicode = decode_punycode('http://.net-xc8g'); # http://☃.net
171+
$unicode = decode_punycode('bcher-kva'); # bücher
172+
$unicode = decode_punycode('ihqwcrb4cv8a8dqg056pqjye'); # 他们为什么不说中文
167173
168-
=head1 FUNCTIONS
174+
=head1 DESCRIPTION
169175
170-
This module exports following functions by default.
176+
L<URI::_punycode> is a module to encode / decode Unicode strings into
177+
L<Punycode|https://tools.ietf.org/html/rfc3492>, an efficient
178+
encoding of Unicode for use with L<IDNA|https://tools.ietf.org/html/rfc5890>.
171179
172-
=over 4
180+
=head1 FUNCTIONS
181+
182+
All functions throw exceptions on failure. You can C<catch> them with
183+
L<Syntax::Keyword::Try> or L<Try::Tiny>. The following functions are exported
184+
by default.
173185
174-
=item encode_punycode
186+
=head2 encode_punycode
175187
176-
$punycode = encode_punycode($unicode);
188+
my $punycode = encode_punycode('http://☃.net'); # http://.net-xc8g
189+
$punycode = encode_punycode('bücher'); # bcher-kva
190+
$punycode = encode_punycode('他们为什么不说中文') # ihqwcrb4cv8a8dqg056pqjye
177191
178-
takes Unicode string (UTF8-flagged variable) and returns Punycode
192+
Takes a Unicode string (UTF8-flagged variable) and returns a Punycode
179193
encoding for it.
180194
181-
=item decode_punycode
195+
=head2 decode_punycode
182196
183-
$unicode = decode_punycode($punycode)
197+
my $unicode = decode_punycode('http://.net-xc8g'); # http://☃.net
198+
$unicode = decode_punycode('bcher-kva'); # bücher
199+
$unicode = decode_punycode('ihqwcrb4cv8a8dqg056pqjye'); # 他们为什么不说中文
184200
185-
takes Punycode encoding and returns original Unicode string.
201+
Takes a Punycode encoding and returns original Unicode string.
186202
187-
=back
203+
=head1 AUTHOR
188204
189-
These functions throw exceptions on failure. You can catch 'em via
190-
C<eval>.
205+
Tatsuhiko Miyagawa <F<[email protected]>> is the author of
206+
L<IDNA::Punycode> which was the basis for this module.
191207
192-
=head1 AUTHOR
208+
=head1 SEE ALSO
209+
210+
L<IDNA::Punycode>, L<RFC 3492|https://tools.ietf.org/html/rfc3492>,
211+
L<RFC 5891|https://tools.ietf.org/html/rfc5891>
193212
194-
Tatsuhiko Miyagawa E<lt>[email protected]E<gt> is the author of
195-
IDNA::Punycode v0.02 which was the basis for this module.
213+
=head1 COPYRIGHT AND LICENSE
196214
197215
This library is free software; you can redistribute it and/or modify
198216
it under the same terms as Perl itself.
199217
200-
=head1 SEE ALSO
201-
202-
L<IDNA::Punycode>, RFC 3492
203-
204218
=cut

0 commit comments

Comments
 (0)