MCPcopy
hub / github.com/go-sql-driver/mysql / escapeStringBackslash

Function escapeStringBackslash

utils.go:642–661  ·  view source on GitHub ↗

escapeStringBackslash is similar to escapeBytesBackslash but for string.

(buf []byte, v string)

Source from the content-addressed store, hash-verified

640
641// escapeStringBackslash is similar to escapeBytesBackslash but for string.
642func escapeStringBackslash(buf []byte, v string) []byte {
643 pos := len(buf)
644 buf = reserveBuffer(buf, len(v)*2+2)
645 buf[pos] = '\''
646 pos++
647 for i := 0; i < len(v); i++ {
648 c := v[i]
649 if esc := backslashEscapeTable[c]; esc != 0 {
650 buf[pos+1] = esc
651 buf[pos] = '\\'
652 pos += 2
653 } else {
654 buf[pos] = c
655 pos++
656 }
657 }
658 buf[pos] = '\''
659 pos++
660 return buf[:pos]
661}
662
663// escapeBytesBackslash appends _binary'...' or '...' with backslash escaping for bytes.
664func escapeBytesBackslash(buf, v []byte, binary bool) []byte {

Callers 2

TestEscapeBackslashFunction · 0.85
interpolateParamsMethod · 0.85

Calls 1

reserveBufferFunction · 0.85

Tested by 1

TestEscapeBackslashFunction · 0.68