phpidn

idn_to_asci error: Could not convert ... to ASCII: Output would be too large or too small


idn_to_ascii(): Could not convert http://www.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaskvaliifidqabddddddddddsddddddddddddd.com to ASCII: Output would be too large or too small

Is there any limit to the url size?


Solution

  • There's a 63-character limit to domain names and your domain exceeds that limit. So basically, this domain couldn't even exist.

    Another possibility of your function failing is if the resulting ASCII-converted domain exceeds 63-characters. E.g. if your domain contains 62 characters and one of them was a non-ASCII character, then the resulting domain would exceed the limit and fail.

    As you can see here, the converted domain is often longer than the original domain: www.cliché.com would return www.xn--clich-fsa.com.

    You can try converting domains here: IDN Conversion Tool

    EDIT
    The idn conversion tool is for converting the domain namne only. Which means that you need to pick out the domain name from the url, convert that part, and then replace that in your original url.

    If you need to convert other parts of the url you probably need to use another function for that.