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 πŸ“

go read the RFCs if you want the deep lore, iykyk. πŸ“š


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