IDN stands for internationalized domain name. It’s a domain containing non-ASCII international character(s). As it is not directly supported by DNS servers translating names to IP addresses, punycode has been used to encode international (Unicode) characters to ASCII characters making it backwards compatible with existing software. This is strictly specified in RFC 3492. For example domain name containing polish characters:
can be encoded as:
In such form it can be used as any other ordinary ASCII domain. You can register such domeain, setup your DNS for it etc. Now let’s say you’d like to use dynamically created URL IDN addresses. For example city-name.example.com. You’ve setup apache ServerAlias *.example.com directive in Apache config and you’re ready to receive requests with your index.php, which might look like this:
Now opening warsaw.example.com will work as expected. But opening for example łódź.example.com will leave you with raw punycode encoded ASCII string. To make it work, try using decoding class below:
I know it’s not perfect. I tried to keep it short and use least PHP extensions as possible. I just hope I gave you general idea behind IDN and dealing with it in PHP.