URI::_punycode(3)
π¦ URI::_punycode(3) β the encode/decode bestie we deserve
okay so real talk: this is URI::_punycode, a little Perl module from the User Contributed Perl Documentation corner of the universe, and it's literally here to turn your pretty Unicode strings into Punycode and back again. no cap, that's the whole vibe. π
β¨ NAME β¨
URI::_punycode β encodes Unicode string in Punycode. that's it, that's the job, and it slays at it. π
πΈ SYNOPSIS πΈ
like, just copy this and you're already iconic:
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 how the snowman β becomes .net-xc8g? that's the glow-up. main character energy fr fr. β
π DESCRIPTION π
so URI::_punycode is a module to encode / decode Unicode strings into Punycode <https://tools.ietf.org/html/rfc3492>, which is an efficient encoding of Unicode for use with IDNA <https://tools.ietf.org/html/rfc5890>.
okay bestie, translating that out of nerd-speak: Punycode is how the internet smuggles fancy Unicode characters through the ASCII-only door, and IDNA is the whole system that lets domain names have emoji and accents and stuff. this module is your little helper for both directions. π§ lowkey essential, highkey underrated.
π FUNCTIONS π
so here's the important tea: all functions throw exceptions on failure. you can "catch" them with Syntax::Keyword::Try or Try::Tiny. don't just let them fly off into the void, bestie. π
The following functions are exported by default β meaning you get them for free, no extra asking. π«Ά
π 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. that's the whole thing β you give it the pretty version, it hands you back the ASCII-safe version. ate and left no crumbs. π₯
π 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. reverse uno card, and it works every time. π
π¦ AUTHOR π¦
Tatsuhiko Miyagawa <miyagawa@bulknews.net> is the author of IDNA::Punycode, which was the basis for this module. shoutout to the og, we're literally standing on their shoulders. π
π SEE ALSO π
IDNA::Punycode- RFC 3492 <https://tools.ietf.org/html/rfc3492>
- RFC 5891 <https://tools.ietf.org/html/rfc5891>
go read the RFCs if you want the deep lore, iykyk. π
β COPYRIGHT AND LICENSE β
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. free as in go wild, just keep the same terms, periodt. π
okay that's the whole page, you're officially Punycode-pilled. go encode a snowman. βοΈ
and finally, the cute sign-off: this lil beauty comes from perl v5.42.0, dated 2026-09-02, and it files itself under URI::_punycode(3) β catch you in the man pages, bestie. π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: perl-URI 5.310.0-160000.3.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms