string_width

Function string_width 

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

Calculate the display width of a string, respecting grapheme clusters.

§Example

use tuxtui_core::util::string_width;

assert_eq!(string_width("Hello"), 5);
assert_eq!(string_width("你好"), 4); // CJK characters are 2 cells wide