PHPackages                             rowbot/punycode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rowbot/punycode

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rowbot/punycode
===============

A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA).

1.0.4(2y ago)1224.0k↑29%1MITPHPPHP &gt;=7.1

Since Jun 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/TRowbotham/punycode)[ Packagist](https://packagist.org/packages/rowbot/punycode)[ RSS](/packages/rowbot-punycode/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (1)

Punycode
========

[](#punycode)

[![Software License](https://camo.githubusercontent.com/1723f89da9f0976205b32fef0af1e95c80df322753bff2bc73ca2ed68ce562bf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f54526f77626f7468616d2f70756e79636f64653f7374796c653d666c61742d737175617265)](https://github.com/TRowbotham/punycode/blob/master/LICENSE)[![GitHub Workflow Status](https://camo.githubusercontent.com/bf1f25297c50d2269bba8a05de9622d5138a8efa47f4e806ec4fb4f965c4bf34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f54526f77626f7468616d2f70756e79636f64652f54657374733f7374796c653d666c61742d737175617265)](https://travis-ci.com/github/TRowbotham/punycode)[![Code Coverage](https://camo.githubusercontent.com/ff37de7b3492c3f6b2b8f9b42ee2fadd32732ed0aef75759ef23a31f2e64f017/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f54526f77626f7468616d2f70756e79636f64652f6d61737465723f7374796c653d666c61742d737175617265)](https://codecov.io/gh/TRowbotham/punycode)[![PHP Version](https://camo.githubusercontent.com/d0db6e9830797894ac39849cc63ea6e61e55ef19cd79a530dc3fe562d8807a2e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f77626f742f70756e79636f64653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rowbot/punycode)[![Total Downloads](https://camo.githubusercontent.com/dfcb1b699aee5d0ec06ae06807c560e88308eeaad86b23e49dad2196c56265e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f77626f742f70756e79636f64653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rowbot/punycode)

An implementation of RFC 3492 Punycode in PHP, based on the sample implementation in [Appendix C](https://tools.ietf.org/html/rfc3492#appendix-C). This is NOT a substitue for `idn_to_ascii` and `idn_to_utf8`.

Requirements
------------

[](#requirements)

- PHP 7.1+

Installation
------------

[](#installation)

```
composer require rowbot/punycode
```

API
---

[](#api)

### Punycode::decode(string $input, int $outLength = null, array &amp;$caseFlags = \[\])

[](#punycodedecodestring-input-int-outlength--null-array-caseflags--)

The `Punycode::decode()` method takes an ASCII encoded string and decodes it to a UTF-8 encoded string. Optionally, the second parameter can be specified to place a limit on the size of the returned string.

#### Parameters

[](#parameters)

- `$input` - An ASCII encoded punycode string to convert to a UTF-8 encoded string.
- `$outLength` - A positive integer representing the maximum length, in code points, of the resulting output string. Defaults to 2,147,483,647.
- `$caseFlags` - An array, which will have the case flag of each character inserted into it.

#### Throws

[](#throws)

- `\Rowbot\Punycode\Exception\OutputSizeExceededException` - If the size of the output string exceeds the maximum size specified.
- `\Rowbot\Punycode\Exception\OverflowException` - If integer overflow occurs.
- `\Rowbot\Punycode\Exception\InvalidInputException` - If input contains non-ASCII bytes or mapping a code point to a digit fails.

```
use Rowbot\Punycode\Punycode;

try {
    echo Punycode::decode('Hello-Another-Way--fc4qua05auwb3674vfr0b'); // Hello-Another-Way-それぞれの場所
} catch (\Rowbot\Punycode\Exception\PunycodeException $e) {
    echo 'An error occured!';
}
```

### Punycode::encode(string $input, int $outLength = null, array $caseFlags = \[\])

[](#punycodeencodestring-input-int-outlength--null-array-caseflags--)

The `Punycode::encode()` method takes a UTF-8 encoded string and converts it into an ASCII encoded punycode string. Optionally, the second parameter can be specified to place a limit on the size of the returned string.

#### Parameters

[](#parameters-1)

- `$input` - A UTF-8 encoded string to convert to punycode.
- `$outLength` - A positive integer representing the maximum length, in code points, of the resulting output string. Defaults to 2,147,483,647.
- `$caseFlags` - An array of bools where true indicates that the character should be uppercase and false indicates that it should be lowercase. This only affects ASCII characters `[a-zA-Z]`.

#### Throws

[](#throws-1)

- `\Rowbot\Punycode\Exception\OutputSizeExceededException` - If the size of the output string exceeds the maximum size specified.
- `\Rowbot\Punycode\Exception\OverflowException` - If integer overflow occurs.

```
use Rowbot\Punycode\Punycode;

try {
    echo Punycode::encode('Hello-Another-Way-それぞれの場所'); // Hello-Another-Way--fc4qua05auwb3674vfr0b
} catch (\Rowbot\Punycode\Exception\PunycodeException $e) {
    echo 'An error occured!';
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~355 days

Total

5

Last Release

746d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/534ea3958dd4732b3d4d4eee1fe459f93695be1bc28391e704be542592c96a89?d=identicon)[Rowbot](/maintainers/Rowbot)

---

Top Contributors

[![TRowbotham](https://avatars.githubusercontent.com/u/4984601?v=4)](https://github.com/TRowbotham "TRowbotham (24 commits)")

---

Tags

phppunycoderfc-3492rfc3492punycoderfc3492rfc-3492

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rowbot-punycode/health.svg)

```
[![Health](https://phpackages.com/badges/rowbot-punycode/health.svg)](https://phpackages.com/packages/rowbot-punycode)
```

###  Alternatives

[opis/uri

Build, parse and validate URIs and URI-templates

1920.8M6](/packages/opis-uri)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
