Skip to main content

grapheme_width

Function grapheme_width 

Source
pub fn grapheme_width(g: &str, eaw_wide: bool) -> u8
Expand description

Display width, in terminal cells, of one extended grapheme cluster.

This function is cluster-aware for the cases that affect terminal layout: it honors text/emoji variation selectors, regional indicators, zero-width joiner sequences, and pictographic default presentation. Non-pictographic clusters use the width of their base code point; combining marks, joiners, and variation selectors in the tail do not add cells.

§Parameters

  • g — one extended grapheme cluster. An empty string has width 0.
  • eaw_wide — East-Asian Ambiguous policy; see char_width.

§Returns

The cluster width in terminal cells.

§Errors and panics

This function does not fail or intentionally panic.