Function display_width

Source
pub fn display_width(s: &str) -> usize
Expand description

Returns the display width of a string, accounting for Unicode double-width and combining characters.

This function sums the display width of each character in the string, using char_display_width.

§Examples

use text_fx::presentation::display_width;

assert_eq!(display_width("hello"), 5); // ASCII
assert_eq!(display_width("你好"), 4);   // CJK
assert_eq!(display_width("á"), 1);    // 'a' + combining accent