Skip to main content

line_to_byte

Function line_to_byte 

Source
pub fn line_to_byte(content: &str, line: usize) -> usize
Expand description

Convert a 1-based line number to byte offset in content. Clamps to content length for safety (last line may not have trailing newline).

Uses char_indices to locate actual newline bytes, ensuring the returned offset always lands on a valid UTF-8 character boundary regardless of multi-byte characters or CRLF line endings.