escapeStringBackslash is similar to escapeBytesBackslash but for string.
(buf []byte, v string)
| 640 | |
| 641 | // escapeStringBackslash is similar to escapeBytesBackslash but for string. |
| 642 | func 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. |
| 664 | func escapeBytesBackslash(buf, v []byte, binary bool) []byte { |