PHP IDN Punycode Converter

The domain name system worked well enough for english, but as the world becomes more connected to the internet, the more people want to use it without typing in domain names using the latin alphabet.

In order to make domain names made up of foreign characters backwards compatible with our existing system, and alternate representation, sometimes called Punycode was defined in RFC3492.

For example the russian domain
can be converted to a latin character safe version:

Example PHP code for converting to and from punycode IDNs:
echo Punycode::encodeHostname('bü')."\n";//outputs
echo Punycode::decodeHostname('')."\n";//outputs bü
//Also japanese
echo Punycode::encodeHostname('ジェーピーニック.jp')."\n";//
echo Punycode::decodeHostname('')."\n";//ジェーピーニック.jp
//Also TLDs
echo Punycode::encodeHostname('')."\n";//www.xn--kpry57d
echo Punycode::decodeHostname('www.xn--kpry57d')."\n";//
* Download punycode.class.php
* GitHub Project Page PHP IDN Library

code snippets are licensed under Creative Commons CC-By-SA 3.0 (unless otherwise specified)