From 90149dede4aae32fd5e719bb22ff3c3b8e480fee Mon Sep 17 00:00:00 2001 From: Roy Falk Date: Mon, 21 Oct 2024 22:11:37 +0300 Subject: [PATCH] Fix bug 865 --- engine/src/cmd/csv.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/engine/src/cmd/csv.cpp b/engine/src/cmd/csv.cpp index a537de5400..b49a3c826a 100644 --- a/engine/src/cmd/csv.cpp +++ b/engine/src/cmd/csv.cpp @@ -32,6 +32,8 @@ #include "unit_json_factory.h" #include "vs_exit.h" +#include + using std::string; std::vector readCSV(const string &s, string delim) { @@ -116,10 +118,18 @@ string writeCSV(const std::map &unit, string delim) { std::string first_line; std::string second_line; for (auto const& pair : unit) { - first_line += addQuote(pair.first, delim); + std::string pair_first = pair.first; + std::string pair_second = pair.second; + + // Replaces standard comma with turned comma (U+2E32) + // Prevents CSV corruption on load. + boost::replace_all(pair_first, ",", "⸲"); + boost::replace_all(pair_second, ",", "⸲"); + + first_line += addQuote(pair_first, delim); first_line += delim[0]; - second_line += addQuote(pair.second, delim); + second_line += addQuote(pair_second, delim); second_line += delim[0]; }