def subdomain_hook_idna(name, domain, kind):
    """New, reliable subdomain hook

    More reliable than previous, should always produce valid domains

    - uses IDNA encoding for simple unicode names
    - separate domain for each service
    - uses stripped name and hash, where above schemes fail to produce a valid domain
    """
    safe_name = _strict_dns_safe_encode(name)
    if kind == 'user':
        # 'user' namespace is special-cased as the default
        # for aesthetics and backward-compatibility for names that don't need escaping
        suffix = ""
    else:
        suffix = f"--{kind}"
    return f"{safe_name}{suffix}.{domain}"
New, reliable subdomain hook

More reliable than previous, should always produce valid domains

- uses IDNA encoding for simple unicode names
- separate domain for each service
- uses stripped name and hash, where above schemes fail to produce a valid domain
jupyterhub/utils.py