pub fn is_binary_content(text: &str) -> boolExpand description
Returns true if text appears to contain binary (non-text) content.
The heuristic checks the first [BINARY_PROBE_BYTES] bytes for null bytes
(\0). A single null byte is sufficient to classify the content as
binary: valid Perl (or any UTF-8 text) never contains null bytes outside of
raw string literals, and real-world binary formats (ELF, PE/COFF, ZIP,
PNG, …) all begin with or contain null bytes in their headers.
§Why null bytes?
- Fast: a single
memchr-style scan of at most 4 KB. - Low false-positive rate: Perl source virtually never contains
\0. - High true-positive rate: every common compiled binary contains
\0.