Skip to main content

looks_like_text

Function looks_like_text 

Source
pub fn looks_like_text(bytes: &[u8]) -> bool
Expand description

Heuristic: does bytes look like UTF-8 text a Nu script could be?

Inspects up to the first [TEXT_PROBE_BYTES] bytes. Rejects when:

  • a NUL byte is present (classic binary marker used by git/file)
  • the sample is not valid UTF-8 (Nu source is UTF-8)
  • more than 30% of bytes are C0 control characters other than tab/LF/CR

Empty input is treated as text (empty script).