The string to clip
The maximum length of the result in code points; 0 or a negative value disables clipping; defaults
to 0
string unaltered if clipping is disabled or string counts no more than length code points; otherwise
its first length-1 code points followed by an ellipsis
Clips a string to a code point budget.
Shortens overlong content, replacing the last retained code point with a
…HORIZONTAL ELLIPSIS, so the result stays within the budget and reports visibly that content was dropped; the ellipsis is itself counted, so a budget of1leaves nothing but the ellipsis.Length is counted in code points rather than UTF-16 code units, so supplementary characters are kept whole and never split into isolated surrogates.
Code points are not glyphs: a grapheme cluster the cut falls inside, an emoji sequence or a base character followed by combining marks among them, is split, and the retained prefix renders on its own.