Truncation
Text Truncation
Shortening text to a specific length, typically adding an ellipsis to indicate omitted content.
Technical Detail
Counting in truncation depends on the definition of 'word' across languages. English words are space-delimited, but Chinese, Japanese, and Thai have no spaces between words and require segmentation algorithms (ICU BreakIterator). Character counting faces similar ambiguity: a single displayed character may be multiple Unicode code points (combining marks, ZWJ sequences, flag emoji). JavaScript's string.length counts UTF-16 code units, not visible characters — [...str].length gives grapheme clusters.
Example
javascript
// Truncation: text processing example
const input = 'Sample text for processing';
const result = input
.trim()
.split(/\s+/)
.filter(Boolean);
console.log(result); // ['Sample', 'text', 'for', 'processing']