def fqdn(name, zone=None):
    """ This produces a string version of a name that is dot terminated
        and ends with the trailing zone.  If the name already ends with
        the zone name, it is not appended.  For example

            (a) -> a.
            (a.) -> a.
            (a,example.com) -> a.example.com.
            (a.example.com,example.com) -> a.example.com.

        the return value is ascii, not unicode

        Note: does not detect multi
    """
    if not name.endswith('.'):
        if zone == None:
            name += '.'
        elif not zone.endswith('.'):
            if name.endswith(zone):
                name = name + '.'
            else:
                name = name + '.' + zone + '.'
        else:
            name += '.'
            if not name.endswith(zone):
                name = name + zone
    return name
