# truncate-width
Longest prefix of a string fitting `w` display cells — a wide glyph
that would straddle the limit is dropped whole, never half-drawn. The
width-aware replacement for byte-based truncation (`len` counts bytes,
so column math drifts on non-ASCII text).
## Syntax
[truncate-width $s $width] # plain truncation [truncate-width $s $width "…"] # ellipsis tail (still fits width)
## Examples
[truncate-width "a中b文cd" 4] # "a中b" (1+2+1 cells; 文 needs 2) [truncate-width "hello world" 8 "…"] # "hello w…" [truncate-width "abc" 5] # "abc" (no truncation → unchanged)
## Returns
String.
## See Also
`width`, `wrap-width`, `pad-width-left`, `pad-width-right`, `draw/text-fit`