This post has been migrated and imported into different systems over the years, I have not had a chance to format this post manually so it may be hard to read but I have left it here as a reference.

So I am sitting here late at night and I registered a few swedish .xyz domains that contain characters åäö. For example you may have the domain for horse in swedish, hä, this domain is actually written as xn– Now I wanted to create a  temporary catch-all page for these swedish domains until I can build a site for them. What I did was to get the domain name as a variable which I echo in the title and body of the page using the following server variable:

this works ok but for domains with äåö it will output the weird looking punycode which is not really seo or user friendly. To solve this we can use the idn_to_utf8() function in PHP which takes the punicode and converts it to UTF-8 characters which will show the åäö characters. For my site I also wanted to make the first character upper case so I used the ucfirst() function. My page ended up looking like this.

    <title><?php echo ucfirst(idn_to_utf8($_SERVER['HTTP_HOST'])); ?> - Coming soon!</title><br></br>
    <h1><?php echo ucfirst(idn_to_utf8($_SERVER['HTTP_HOST'])); ?></h1><br></br>

That takes care of that. Now the opposite function of idn_to_utf8() is the idn_to_ascii() function. This will take the åäö characters and convert them to the punycode.

I hope some of you find this useful.