QDenka / Punycode

A simple PHP library for encoding and decoding URLs to and from Punycode.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Punycode Converter

License Build Status Coverage Status

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/');

About

A simple PHP library for encoding and decoding URLs to and from Punycode.

License:Other


Languages

Language:PHP 100.0%