(b []byte)
| 220 | } |
| 221 | |
| 222 | func likelyBinary(b []byte) bool { |
| 223 | if len(b) == 0 { |
| 224 | return false |
| 225 | } |
| 226 | if len(b) > 8000 { |
| 227 | b = b[:8000] |
| 228 | b = trimIncompleteUTF8(b) // in case we broke a multi-byte char |
| 229 | } |
| 230 | return slices.Contains(b, 0) || !utf8.Valid(b) |
| 231 | } |
| 232 | |
| 233 | func trimIncompleteUTF8(b []byte) []byte { |
| 234 | for i := 0; i < 3 && len(b) > 0; i++ { |
no test coverage detected