Skip to main content

display_width

Function display_width 

Source
pub fn display_width(text: &str) -> usize
Expand description

Calculate the display width of text in cells.

Uses ASCII fast-path when possible, falling back to Unicode width calculation.

If FTUI_TEXT_CJK_WIDTH=1 (or FTUI_CJK_WIDTH=1) or a CJK locale is detected, ambiguous-width characters are treated as double-width.

ยงPerformance

  • ASCII text: O(n) byte scan, no allocations
  • Non-ASCII: Grapheme segmentation + per-grapheme width