MCPcopy Create free account
hub / github.com/araddon/qlbridge / LiteralQuoteEscape

Function LiteralQuoteEscape

expr/stringutil.go:165–176  ·  view source on GitHub ↗

LiteralQuoteEscape escape string that may need characters escaped LiteralQuoteEscape("'","item's") => 'item''s' LiteralQuoteEscape(`"`,"item's") => "item's" LiteralQuoteEscape(`"`,`item"s`) => "item""s"

(quote rune, literal string)

Source from the content-addressed store, hash-verified

163// LiteralQuoteEscape(`"`,`item"s`) => "item""s"
164//
165func LiteralQuoteEscape(quote rune, literal string) string {
166 if len(literal) > 1 {
167 quoteb := byte(quote)
168 if literal[0] == quoteb && literal[len(literal)-1] == quoteb {
169 // Already escaped??
170 return literal
171 }
172 }
173 var buf bytes.Buffer
174 LiteralQuoteEscapeBuf(&buf, quote, literal)
175 return buf.String()
176}
177
178// LiteralQuoteEscapeBuf escape string that may need characters escaped
179//

Callers 2

TestLiteralEscapingFunction · 0.85
WriteIdentityMethod · 0.85

Calls 2

LiteralQuoteEscapeBufFunction · 0.85
StringMethod · 0.65

Tested by 1

TestLiteralEscapingFunction · 0.68