def stripnull(string, null=b'\x00'):
    """Return string truncated at first null character.

    Clean NULL terminated C strings. For unicode strings use null='\\0'.

    """
    i = string.find(null)
    return string if i < 0 else string[:i]
