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)
| 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. |
| 20 | func 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). |
no outgoing calls