logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

URI::_punycode - encodes Unicode string in Punycode

Author

       Tatsuhiko Miyagawa <miyagawa@bulknews.net> is the author of IDNA::Punycode which was the basis for this
       module.

Description

       URI::_punycode is a module to encode / decode Unicode strings into Punycode
       <https://tools.ietf.org/html/rfc3492>, an efficient encoding of Unicode for use with IDNA
       <https://tools.ietf.org/html/rfc5890>.

Functions

       All functions throw exceptions on failure. You can "catch" them with Syntax::Keyword::Try or Try::Tiny.
       The following functions are exported by default.

   encode_punycode
         my $punycode = encode_punycode('http://☃.net');  # http://.net-xc8g
         $punycode = encode_punycode('bücher'); # bcher-kva
         $punycode = encode_punycode('他们为什么不说中文') # ihqwcrb4cv8a8dqg056pqjye

       Takes a Unicode string (UTF8-flagged variable) and returns a Punycode encoding for it.

   decode_punycode
         my $unicode = decode_punycode('http://.net-xc8g'); # http://☃.net
         $unicode = decode_punycode('bcher-kva'); # bücher
         $unicode = decode_punycode('ihqwcrb4cv8a8dqg056pqjye'); # 他们为什么不说中文

       Takes a Punycode encoding and returns original Unicode string.

Name

       URI::_punycode - encodes Unicode string in Punycode

See Also

       IDNA::Punycode, RFC 3492 <https://tools.ietf.org/html/rfc3492>, RFC 5891
       <https://tools.ietf.org/html/rfc5891>

Synopsis

         use strict;
         use warnings;
         use utf8;

         use URI::_punycode qw(encode_punycode decode_punycode);

         # encode a unicode string
         my $punycode = encode_punycode('http://☃.net'); # http://.net-xc8g
         $punycode = encode_punycode('bücher'); # bcher-kva
         $punycode = encode_punycode('他们为什么不说中文'); # ihqwcrb4cv8a8dqg056pqjye

         # decode a punycode string back into a unicode string
         my $unicode = decode_punycode('http://.net-xc8g'); # http://☃.net
         $unicode = decode_punycode('bcher-kva'); # bücher
         $unicode = decode_punycode('ihqwcrb4cv8a8dqg056pqjye'); # 他们为什么不说中文

See Also