URI::\_punycode(3) User Contributed Perl Documentation URI::\_punycode(3)

# [NAME](#NAME)

URI::\_punycode - encodes Unicode string in Punycode

# [SYNOPSIS](#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'); # 他们为什么不说中文
```

# [DESCRIPTION](#DESCRIPTION)

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

# [FUNCTIONS](#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](#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](#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.

# [AUTHOR](#AUTHOR)

Tatsuhiko Miyagawa &lt;*miyagawa@bulknews.net*&gt; is the author of IDNA::Punycode which was the basis for this module.

# [SEE ALSO](#SEE_ALSO)

IDNA::Punycode, RFC 3492 &lt;https://tools.ietf.org/html/rfc3492&gt;, RFC 5891 &lt;https://tools.ietf.org/html/rfc5891&gt;

# [COPYRIGHT AND LICENSE](#COPYRIGHT_AND_LICENSE)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2026-10-26 perl v5.44.0

---

Document: URI::_punycode(3pm) from perl-uri 5.40-r2 (Chainguard OS)
Source: https://github.com/libwww-perl/URI.git
