pub fn visual_len(text: &str) -> usizeExpand description
Calculate the visible character count (char-based, Tier 1).
Counts characters that would be visible in terminal output, ignoring ANSI escape sequences.
§Arguments
text- Input text potentially containing ANSI escape sequences
§Returns
Number of visible characters (Unicode codepoints, not graphemes).
§Examples
use strs_tools::ansi::visual_len;
assert_eq!( visual_len( "hello" ), 5 );
assert_eq!( visual_len( "\x1b[31mred\x1b[0m" ), 3 );
assert_eq!( visual_len( "\x1b[1;31mbold red\x1b[0m" ), 8 );§Performance
- Time complexity: O(n)
- Benchmark: ~100ns/KB on modern hardware