MCPcopy Create free account
hub / github.com/araddon/qlbridge / escapeString

Function escapeString

exec/sqldriver.go:399–430  ·  view source on GitHub ↗
(txt string)

Source from the content-addressed store, hash-verified

397}
398
399func escapeString(txt string) string {
400 var (
401 esc string
402 buf bytes.Buffer
403 )
404 last := 0
405 for ii, bb := range txt {
406 switch bb {
407 case 0:
408 esc = `\0`
409 case '\n':
410 esc = `\n`
411 case '\r':
412 esc = `\r`
413 case '\\':
414 esc = `\\`
415 case '\'':
416 esc = `\'`
417 case '"':
418 esc = `\"`
419 case '\032':
420 esc = `\Z`
421 default:
422 continue
423 }
424 io.WriteString(&buf, txt[last:ii])
425 io.WriteString(&buf, esc)
426 last = ii + 1
427 }
428 io.WriteString(&buf, txt[last:])
429 return buf.String()
430}
431
432func escapeQuotes(txt string) string {
433 var buf bytes.Buffer

Callers 1

queryArgsConvertFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected