quoteCSVString wraps a string in double quotes and escapes internal quotes.
(s string)
| 85 | |
| 86 | // quoteCSVString wraps a string in double quotes and escapes internal quotes. |
| 87 | func quoteCSVString(s string) []byte { |
| 88 | escaped := escapeCSVString(s) |
| 89 | result := make([]byte, 0, len(escaped)+2) |
| 90 | result = append(result, '"') |
| 91 | result = append(result, []byte(escaped)...) |
| 92 | result = append(result, '"') |
| 93 | return result |
| 94 | } |
| 95 | |
| 96 | func escapeCSVString(str string) string { |
| 97 | return strings.ReplaceAll(str, `"`, `""`) |
no test coverage detected