LiteralQuoteEscapeBuf escape string that may need characters escaped LiteralQuoteEscapeBuf("'","item's") => 'item''s' LiteralQuoteEscapeBuf(`"`,"item's") => "item's" LiteralQuoteEscapeBuf(`"`,`item"s`) => "item""s"
(buf *bytes.Buffer, quote rune, literal string)
| 182 | // LiteralQuoteEscapeBuf(`"`,`item"s`) => "item""s" |
| 183 | // |
| 184 | func LiteralQuoteEscapeBuf(buf *bytes.Buffer, quote rune, literal string) { |
| 185 | if len(literal) > 1 { |
| 186 | quoteb := byte(quote) |
| 187 | if literal[0] == quoteb && literal[len(literal)-1] == quoteb { |
| 188 | // Already escaped?? |
| 189 | io.WriteString(buf, literal) |
| 190 | return |
| 191 | } |
| 192 | } |
| 193 | buf.WriteByte(byte(quote)) |
| 194 | escapeQuote(buf, quote, literal) |
| 195 | if quote == '[' { |
| 196 | buf.WriteByte(']') |
| 197 | } else { |
| 198 | buf.WriteByte(byte(quote)) |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | // StringEscape escape string that may need characters escaped |
| 203 | // |
no test coverage detected