def win_safe_name(trackname):
    """Edit the track name so as the resulting file name would be
    allowed in Windows.
    """
    # In order: strip the whitespace at both ends, replace a trailing
    # full stop by an underscore.  Replace any forbidden characters by
    # underscores.
    trackname = trackname.strip()
    if trackname.endswith("."):
        trackname = trackname[:-1] + "_"
    for chr in trackname:
        if chr in ("<", ">", ":", "/", "\\", "|", "?", "*", "\""):
            trackname = trackname.replace(chr, "_")
        # Check for null chars just in case
        elif chr == "\0":
            trackname = trackname.replace(chr, "")
    return trackname