Skip to main content

width

Function width 

Source
pub fn width(value: &str) -> usize
Expand description

The width of a string in terminal columns.

use majordomus_cli::environment::text::width;
assert_eq!(width("majordomus"), 10);
assert_eq!(width("přehled"), 7, "a two-byte character is one column");
assert_eq!(width("日本語"), 6, "a wide character is two");
assert_eq!(width("e\u{0301}"), 1, "a combining accent adds none");
assert_eq!(width("◆ ✓ ✱"), 5);