Skip to main content

is_binary

Function is_binary 

Source
pub fn is_binary(path: &Path, check_bytes: usize) -> bool
Expand description

Returns true when the file looks like binary content.

The heuristic reads the first check_bytes bytes of the file and checks:

  • whether a null byte (\0) is present — classic binary signal
  • whether the bytes fail UTF-8 decoding

Any IO error is treated conservatively as “binary” so the file is skipped.