Skip to main content

char_width

Function char_width 

Source
pub fn char_width(c: char) -> usize
Expand description

Columns a single char occupies, using Width::DEFAULT.

Remember that a char is not a user-perceived character; prefer width for real text.

Examples found in repository?
examples/dump_widths.rs (line 7)
3fn main() {
4    let mut out = String::new();
5    for cp in 0u32..=0x10FFFF {
6        if let Some(c) = char::from_u32(cp) {
7            out.push_str(&format!("{cp}\t{}\n", cellwidth::char_width(c)));
8        }
9    }
10    print!("{out}");
11}