def convert_to_raw(string, exceptions=''):
    """
    Converts a string to its raw form, converting all backslash to double
    backslash except when the backslash escapes a character given in
    exceptions.

    :param string:     The given string that needs to be converted
    :param exceptions: A list of characters that if escaped with backslash
                       should not be converted to double backslash.
    :return:           Returns the corresponding raw string.
    """
    i = 0
    length = len(string)
    output = ''
    while i < length:
        if string[i] == '\\' and i + 1 < length and string[i + 1
            ] not in exceptions:
            output += '\\'
            if string[i + 1] == '\\':
                i += 1
        output += string[i]
        i += 1
    return output
