Search code examples
database-designdnsmaxlengthidnpunycode

What is the maximum length of an IDNA converted domain name?


First things first:

I'm storing multiple domains to a database, after I've converted each and every domain name to it's IDNA version. What I need to know the maximum length such an IDNA-converted domain name can have so I can define the database field's max length.

Known fact:

Now, I know the maximum number of characters in a domain name (including any subdomains) is 255 characters.

Where I lost it:

That's easy at first glance, but... does this mean regular ascii characters of international characters (think UTF-8 encoding)?

To give you an example: The domain "müller.de" has 9 characters when I ignore that "ü" is an international character that needs more bytes to be represented. The IDNA version of "müller.de" is "xn--mller-kva.de", which has 16 characters. This shows there's definitely a difference in maximum length depending on "if" it is IDNA converted or not.

Depending on what kind of characters they mean, the 255-character maximum could be the international character version, the IDNA converted version or even both.

And that's where I lost it a bit... especially, since I have to take into account that not all domains will be sane and stuff like "öüßüöäéèê.example.äöüßüöäéèê-äöüßüöäéèê.test.äöüßüöäéèê.com" and even worse is to be expected.

So, "guessing" and "hoping for the best" is not an option. I need to know for sure...

The question is:

Based on the known fact that the maximum number of characters in a domain name (including any subdomains) is 255 characters... what is the maximum length of an IDNA converted domain name?

Or did they mean the IDNA converted version (punycode) is also restricted to 255 characters (which would mean that domains with international/unicode characters would actually have shorter limits in their unicode representation, because their IDNA converted version would have to respect the 255 char limit)?


Solution

  • My understanding is that the 255-character limit is to be considered after the IDNA conversion.

    This is because DNS records have this character limit, and in general DNS records can only contain letters, digits and hyphens (from Wikipedia). The DNS server therefore uses the Punycode version of the IDN for its record, not the Unicode version.