Function char_display_width

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

Returns the display width of a single Unicode character.

  • Control and combining characters have width 0.
  • CJK and wide symbols have width 2.
  • Most other characters have width 1.

§Examples

use text_fx::presentation::char_display_width;

assert_eq!(char_display_width('a'), 1);
assert_eq!(char_display_width('你'), 2);
assert_eq!(char_display_width('\u{0301}'), 0); // combining acute accent