waIdna

Class for handling Punycode-encoded URLs written in national alphabets

Contents...

Methods

public static function dec ($str)

Returns domain name written in a national alphabet, for specified Punycode string.

Parameters

Example

waIdna::dec('xn--d1acklchcc.xn--p1ai');

Result

мойдомен.рф

public static function enc ($str)

Returns Punycode version of a domain name written in a national alphabet.

Parameters

Example

waIdna::enc('мойдомен.рф');

Result

xn--d1acklchcc.xn--p1ai

public function encode_uri ($uri)

Returns a URI written in a national alphabet, with a domain name encoded to Punycode. Other parts of a URI, except for a domain name, are not encoded to Punycode. A URI must contain a domain name.

Parameters

Example

$idna = new waIdna();
$idna->encode_uri('https://мойдомен.рф/вакансии/');

Result

https://xn--d1acklchcc.xn--p1ai/вакансии/