MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / escapeQuotedString

Function escapeQuotedString

pkg/sql/ast/value.go:201–220  ·  view source on GitHub ↗
(s string, quote rune)

Source from the content-addressed store, hash-verified

199}
200
201func escapeQuotedString(s string, quote rune) string {
202 var result strings.Builder
203 prevChar := rune(0)
204 chars := []rune(s)
205 for i := 0; i < len(chars); i++ {
206 ch := chars[i]
207 if ch == quote {
208 if prevChar == '\\' {
209 result.WriteRune(ch)
210 continue
211 }
212 result.WriteRune(ch)
213 result.WriteRune(ch)
214 } else {
215 result.WriteRune(ch)
216 }
217 prevChar = ch
218 }
219 return result.String()
220}
221
222func escapeEscapedString(s string) string {
223 var result strings.Builder

Callers 3

escapeSingleQuoteStringFunction · 0.85
escapeDoubleQuoteStringFunction · 0.85
TestEscapeQuotedStringFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by 1

TestEscapeQuotedStringFunction · 0.68