MCPcopy Create free account
hub / github.com/bytebase/bytebase / quoteCSVString

Function quoteCSVString

backend/component/export/csv.go:87–94  ·  view source on GitHub ↗

quoteCSVString wraps a string in double quotes and escapes internal quotes.

(s string)

Source from the content-addressed store, hash-verified

85
86// quoteCSVString wraps a string in double quotes and escapes internal quotes.
87func 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
96func escapeCSVString(str string) string {
97 return strings.ReplaceAll(str, `"`, `""`)

Callers 1

convertValueToBytesInCSVFunction · 0.85

Calls 1

escapeCSVStringFunction · 0.85

Tested by

no test coverage detected