MCPcopy Create free account
hub / github.com/cli/cli / ContainsEscapeSequence

Function ContainsEscapeSequence

pkg/iostreams/content.go:20–32  ·  view source on GitHub ↗

ContainsEscapeSequence reports whether b contains an ANSI escape byte (0x1B) or a UTF-8-encoded C1 control character (U+0080 to U+009F), either of which can start a sequence that manipulates a terminal when printed.

(b []byte)

Source from the content-addressed store, hash-verified

18// or a UTF-8-encoded C1 control character (U+0080 to U+009F), either of which
19// can start a sequence that manipulates a terminal when printed.
20func ContainsEscapeSequence(b []byte) bool {
21 if bytes.IndexByte(b, 0x1B) >= 0 {
22 return true
23 }
24 for len(b) > 0 {
25 r, size := utf8.DecodeRune(b)
26 if r >= 0x80 && r <= 0x9F {
27 return true
28 }
29 b = b[size:]
30 }
31 return false
32}
33
34// BinaryContentType reports whether content appears to be binary and, if so,
35// returns its detected MIME type. Textual content returns ("", false).

Callers 5

viewRunFunction · 0.92
readFileRunFunction · 0.92
diffRunFunction · 0.92
CopyGuardedContentFunction · 0.85

Calls

no outgoing calls

Tested by 1