pub fn char_width(c: char) -> u16Expand description
The number of terminal cells a single character occupies.
Returns 1 for most characters, including control characters (unicode-width reports no
width for these; 1 matches what Surface actually draws and what
Tile::width tells the terminal to advance by, so this function agrees
with the rest of the crate instead of undercounting), 2 for wide characters (CJK, most
emoji), and 0 for combining marks (these genuinely occupy no column of their own).
§Examples
use retroglyph_core::text::char_width;
assert_eq!(char_width('a'), 1);
assert_eq!(char_width('中'), 2);
assert_eq!(char_width('\u{0301}'), 0); // combining acute accent
assert_eq!(char_width('\u{7}'), 1); // BEL: a control character, not a combining mark