Skip to main content

max_line_length_c

Function max_line_length_c 

Source
pub fn max_line_length_c(data: &[u8]) -> u64
Expand description

Compute maximum display width of any line (C/POSIX locale).

GNU wc -L behavior in C locale:

  • \n: line terminator (records max, resets position)
  • \t: advances to next tab stop (multiple of 8)
  • \r: carriage return (resets position to 0, same line)
  • \f: form feed (acts as line terminator like \n)
  • Printable ASCII (0x20..0x7E): width 1
  • Everything else (controls, high bytes): width 0

Optimized with printable ASCII run counting: for runs of bytes in 0x21-0x7E (no space/tab/newline), counts the entire run length at once.