MCPcopy Create free account
hub / github.com/segmentio/encoding / Escape

Function Escape

json/json.go:221–226  ·  view source on GitHub ↗

Escape is a convenience helper to construct an escaped JSON string from s. The function escales HTML characters, for more control over the escape behavior and to write to a pre-allocated buffer, use AppendEscape.

(s string)

Source from the content-addressed store, hash-verified

219// The function escales HTML characters, for more control over the escape
220// behavior and to write to a pre-allocated buffer, use AppendEscape.
221func Escape(s string) []byte {
222 // +10 for extra escape characters, maybe not enough and the buffer will
223 // be reallocated.
224 b := make([]byte, 0, len(s)+10)
225 return AppendEscape(b, s, EscapeHTML)
226}
227
228// AppendEscape appends s to b with the string escaped as a JSON value.
229// This will include the starting and ending quote characters, and the

Callers 1

TestEscapeStringFunction · 0.85

Calls 1

AppendEscapeFunction · 0.85

Tested by 1

TestEscapeStringFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…