Skip to main content

is_binary_bytes

Function is_binary_bytes 

Source
pub fn is_binary_bytes(data: &[u8]) -> bool
Expand description

Determine if the provided byte slice should be treated as binary.

The heuristic mirrors common implementations used by tools such as ripgrep and git. A slice is considered binary if:

  • It contains a NUL byte (0x00), or
  • More than 30% of bytes are outside the printable ASCII range.