def force_punycode_domain_name(s):
    """
    Converts human-readable IDN domain to punycode.
    """
    if s is None:
        return s
    s = s.lower().strip()
    if s.startswith('xn--'):
        return s
    else:
        try:
            result = s.encode('idna')
        except TypeError:
            result = s.decode('utf-8').encode('idna')
        return result.decode()
