true/punycode
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
symfony/polyfill-mbstring | v1.29.0 | - | MIT | prod |
The true/punycode is a PHP library designed for the conversion of Unicode to ASCII and vice versa. This is particularly useful for the encoding of Internationalized Domain Names in Applications (IDNA). It leverages the Bootstring encoding method, allowing you to represent Unicode within the limited character subset of ASCII, ideal for domain names.
True/punycode installation and usage are simple. First, install the package via Composer by running the following command in your terminal or command prompt:
composer require true/punycode:~2.0
Then, you can use it in your PHP code, like so:
<?php
// Import Punycode
use TrueBV\Punycode;
$Punycode = new Punycode();
var_dump($Punycode->encode('renangonçalves.com'));
// It outputs: xn--renangonalves-pgb.com
var_dump($Punycode->decode('xn--renangonalves-pgb.com'));
// It outputs: renangonçalves.com
With the above code, you're able to encode and decode a domain name using Punycode. In this instance, the domain name 'renangonçalves.com' is Punycode encoded and then decoded.
While the true/punycode README on GitHub provides essential information about the library, it does not clearly specify a dedicated documentation site. However, given the tool's simplicity, the GitHub README itself effectively serves as documentation, providing all the necessary guidance for installation and utilization of the library. For deeper understanding, code inspection would be useful. Bear in mind that this library is intended to provide a solution for users unable to install PECL extensions or who write portable code across multiple hosts, including Windows and macOS.