escapeStringQuotes is similar to escapeBytesQuotes but for string.
(buf []byte, v string)
| 716 | |
| 717 | // escapeStringQuotes is similar to escapeBytesQuotes but for string. |
| 718 | func escapeStringQuotes(buf []byte, v string) []byte { |
| 719 | pos := len(buf) |
| 720 | buf = reserveBuffer(buf, len(v)*2+2) |
| 721 | buf[pos] = '\'' |
| 722 | pos++ |
| 723 | for i := range len(v) { |
| 724 | c := v[i] |
| 725 | if c == '\'' { |
| 726 | buf[pos+1] = '\'' |
| 727 | buf[pos] = '\'' |
| 728 | pos += 2 |
| 729 | } else { |
| 730 | buf[pos] = c |
| 731 | pos++ |
| 732 | } |
| 733 | } |
| 734 | buf[pos] = '\'' |
| 735 | pos++ |
| 736 | return buf[:pos] |
| 737 | } |
| 738 | |
| 739 | /****************************************************************************** |
| 740 | * Sync utils * |