capUntrustedText
capUntrustedText(
text,maxChars,marker):string
Defined in: packages/core/src/utils/untrustedText.ts:110
Truncate untrusted text at maxChars, SURROGATE-SAFE, appending marker only when text was
actually clipped.
A naive slice(0, N) can split a surrogate pair (e.g. an emoji) at the boundary and emit a lone
half-code-unit. If the cut would land between a high and a low surrogate, back off one code unit
so the pair is kept whole (dropped entirely rather than split).
Parameters
Section titled “Parameters”string
maxChars
Section titled “maxChars”number
marker
Section titled “marker”string
Returns
Section titled “Returns”string