Correctly encapsulates CSV special characters and doubles quotation marks for valid CSV
| 866 | |
| 867 | /// Correctly encapsulates CSV special characters and doubles quotation marks for valid CSV |
| 868 | std::string escape_csv_value(const std::string& value) { |
| 869 | // only escape if special " characters present |
| 870 | std::string escaped; |
| 871 | escaped.reserve(value.size()); |
| 872 | |
| 873 | for (char c : value) { |
| 874 | if (c == '"') |
| 875 | escaped += "\"\""; // double quotation marks |
| 876 | else |
| 877 | escaped += c; |
| 878 | } |
| 879 | return escaped; |
| 880 | } |
| 881 | |
| 882 | /// Converts all XML reserved characters in the string to their safe entity codes for valid XML |
| 883 | std::string escape_xml_value(const std::string& value) { |
no test coverage detected