def _escape_contents_for_single_line(contents: str) -> str:
    """Escape characters to write as a single line.

    :param contents: The contents to escape.
    :return: The contents with \r, \n and " escaped

    """
    contents = contents.replace("\r", "\\r").replace("\n", "\\n").replace('"', '\\"')

    return contents