Skip to main content

is_text_bytes

Function is_text_bytes 

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

The text judgement over a window of bytes: no NUL byte.

use majordomus_cli::scope::is_text_bytes;
assert!(is_text_bytes(b"version: 1\n"));
assert!(is_text_bytes("příručka".as_bytes()));
assert!(is_text_bytes(b"caf\xe9"), "an encoding is not a binary; the reader refuses it");
assert!(!is_text_bytes(b"\x89PNG\r\n\x1a\n\x00"));