MCPcopy Create free account
hub / github.com/F-Stack/f-stack / csv_escape

Function csv_escape

tools/libxo/encoder/csv/enc_csv.c:302–316  ·  view source on GitHub ↗

* Escape the string, following the rules in RFC4180 */

Source from the content-addressed store, hash-verified

300 * Escape the string, following the rules in RFC4180
301 */
302static void
303csv_escape (xo_buffer_t *xbp, const char *value, size_t len)
304{
305 const char *cp, *ep, *np;
306
307 for (cp = value, ep = value + len; cp && cp < ep; cp = np) {
308 np = strchr(cp, '"');
309 if (np) {
310 np += 1;
311 xo_buf_append(xbp, cp, np - cp);
312 xo_buf_append(xbp, "\"", 1);
313 } else
314 xo_buf_append(xbp, cp, ep - cp);
315 }
316}
317
318/*
319 * Append a newline to the buffer, following the settings of the "dos"

Callers 1

csv_emit_recordFunction · 0.85

Calls 2

strchrFunction · 0.85
xo_buf_appendFunction · 0.85

Tested by

no test coverage detected