MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / escapeCsvString

Function escapeCsvString

tools/shell/embedded_shell.cpp:1056–1074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1054}
1055
1056std::string escapeCsvString(const std::string& field, const std::string& delimiter) {
1057 bool needsQuoting =
1058 field.find_first_of("\"" + delimiter + "\n") != std::string::npos || field.empty();
1059 if (!needsQuoting) {
1060 return field;
1061 }
1062
1063 std::ostringstream quotedField;
1064 quotedField << '"';
1065 for (char c : field) {
1066 if (c == '"') {
1067 quotedField << "\"\"";
1068 } else {
1069 quotedField << c;
1070 }
1071 }
1072 quotedField << '"';
1073 return quotedField.str();
1074}
1075
1076// TODO(Ziyi): Move the printing logic under each printer and each printer should expose a unified
1077// `print` interface.

Callers 1

printExecutionResultMethod · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected