qdenka / punycode
A simple PHP library for encoding and decoding URLs to and from Punycode.
Installs: 2 222
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- ext-intl: *
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: >=8.5
This package is auto-updated.
Last update: 2025-04-25 10:34:30 UTC
README
Punycode Converter is a PHP library that provides functions to encode and decode URLs using Punycode.
Installation
You can install the library via Composer. Run the following command:
composer require qdenka/punycode
Usage Punycode Converter
use Qdenka\Punycode\Converter; // Encode a URL to Punycode $encodedUrl = Converter::encode('http://www.üñïçø∂é.com/привет#мир'); // Decode a Punycode URL back to its original form $decodedUrl = Converter::decode('http://xn--tda.com/'); // Encode an array of URLs to Punycode $urls = ['http://www.üñïçø.com/testcase', 'ßlåh.com']; $encodedUrls = Converter::encodeFromArray($urls); // Decode an array of Punycode URLs back to their original forms $punycodeUrls = ['xn--tda.com', 'http://www.example.com/url1']; $decodedUrls = Converter::decodeFromArray($punycodeUrls);
Usage Punycode Identifier
use Qdenka\Punycode\Identifier; // Check if a URL is encoded IDN $isPunycode = Identifier::isPunycode('http://xn--tda.com/'); // Check if a URL is Ascii $isNotPunycode = Identifier::isUnicode('http://www.üñïçø.com/');