@@ -147,58 +147,72 @@ sub min {
147
147
1;
148
148
__END__
149
149
150
+ =encoding utf8
151
+
150
152
=head1 NAME
151
153
152
154
URI::_punycode - encodes Unicode string in Punycode
153
155
154
156
=head1 SYNOPSIS
155
157
156
- use URI::_punycode ;
157
- $punycode = encode_punycode($unicode) ;
158
- $unicode = decode_punycode($punycode) ;
158
+ use strict ;
159
+ use warnings ;
160
+ use utf8 ;
159
161
160
- =head1 DESCRIPTION
162
+ use URI::_punycode qw(encode_punycode decode_punycode);
161
163
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
164
168
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'); # 他们为什么不说中文
167
173
168
- =head1 FUNCTIONS
174
+ =head1 DESCRIPTION
169
175
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> .
171
179
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.
173
185
174
- =item encode_punycode
186
+ =head2 encode_punycode
175
187
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
177
191
178
- takes Unicode string (UTF8-flagged variable) and returns Punycode
192
+ Takes a Unicode string (UTF8-flagged variable) and returns a Punycode
179
193
encoding for it.
180
194
181
- =item decode_punycode
195
+ =head2 decode_punycode
182
196
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'); # 他们为什么不说中文
184
200
185
- takes Punycode encoding and returns original Unicode string.
201
+ Takes a Punycode encoding and returns original Unicode string.
186
202
187
- =back
203
+ =head1 AUTHOR
188
204
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 .
191
207
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>
193
212
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
196
214
197
215
This library is free software; you can redistribute it and/or modify
198
216
it under the same terms as Perl itself.
199
217
200
- =head1 SEE ALSO
201
-
202
- L<IDNA::Punycode> , RFC 3492
203
-
204
218
=cut
0 commit comments