Skip to main content

byte_offset_at_visual_column

Function byte_offset_at_visual_column 

Source
pub fn byte_offset_at_visual_column(s: &str, visual_col: usize) -> usize
Expand description

Convert a visual column to a byte offset within a string.

Returns the byte offset of the character that starts at or after the given visual column. If the visual column is beyond the string’s width, returns the string’s length. This ensures the result is always at a valid UTF-8 character boundary.