human
Complete this python program:
def _dnsname_to_stdlib(name):
assistant
#Here is the Python code you requested.

    """Converts a dNSName SubjectAlternativeName field to the form used by the
    standard library on the given Python version.
    Cryptography produces a dNSName as a unicode string that was idna-decoded
    from ASCII bytes. We need to idna-encode that string to get it back, and
    then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib
    uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8).
    """
    def idna_encode(name):
        "\n                                Borrowed    wholesale    from    the    Python    Cryptography    Project.    It    turns    out\n                                that    we    can't    just    safely    call    `idna.encode`:    it    can    explode    for\n                                wildcard    names.    This    avoids    that    problem.\n                                "
        import idna
        for prefix in [u'*.', u'.']:
            if name.startswith(prefix):
                name = name[len(prefix):]
                return (prefix.encode('ascii') + idna.encode(name))
        return idna.encode(name)
    name = idna_encode(name)
    if (sys.version_info >= (3, 0)):
        name = name.decode('utf-8')
    return name