escapeBytesBackslash appends _binary'...' or '...' with backslash escaping for bytes.
(buf, v []byte, binary bool)
| 662 | |
| 663 | // escapeBytesBackslash appends _binary'...' or '...' with backslash escaping for bytes. |
| 664 | func escapeBytesBackslash(buf, v []byte, binary bool) []byte { |
| 665 | pos := len(buf) |
| 666 | if binary { |
| 667 | buf = reserveBuffer(buf, len(v)*2+9) |
| 668 | copy(buf[pos:], []byte("_binary'")) |
| 669 | pos += 8 |
| 670 | } else { |
| 671 | buf = reserveBuffer(buf, len(v)*2+2) |
| 672 | buf[pos] = '\'' |
| 673 | pos++ |
| 674 | } |
| 675 | for _, c := range v { |
| 676 | if esc := backslashEscapeTable[c]; esc != 0 { |
| 677 | buf[pos+1] = esc |
| 678 | buf[pos] = '\\' |
| 679 | pos += 2 |
| 680 | } else { |
| 681 | buf[pos] = c |
| 682 | pos++ |
| 683 | } |
| 684 | } |
| 685 | buf[pos] = '\'' |
| 686 | pos++ |
| 687 | return buf[:pos] |
| 688 | } |
| 689 | |
| 690 | // escapeBytesQuotes appends _binary'...' or '...' with single-quote escaping for bytes. |
| 691 | func escapeBytesQuotes(buf, v []byte, binary bool) []byte { |