Skip to main content

char_width

Function char_width 

Source
pub fn char_width(c: char, eaw_wide: bool) -> u8
Expand description

Display width, in terminal cells, of a single code point.

This function is cluster-blind. It reports width for c alone: 0 for controls and zero-width formatting/mark code points, 2 for code points whose East-Asian-Width property is Wide or Fullwidth, and 1 for most other printable code points.

eaw_wide selects the East-Asian Ambiguous policy: when true, ambiguous code points, including many Greek, Cyrillic, and box-drawing characters, are reported as two cells; when false, they are reported as one.

§Parameters

  • c — Unicode scalar value to measure.
  • eaw_wide — whether East-Asian Ambiguous code points count as wide.

§Returns

The display width in terminal cells.

§Errors and panics

This function does not fail or intentionally panic.