SANJIESAN TOOLS / Text limits
Define what the text limit counts before cutting a title
A title limit labelled characters can hide several different counting rules. A visible symbol may contain multiple underlying text units, and Chinese word boundaries are not simply spaces. Before automatically shortening resource names, define the user-facing rule and the storage constraint separately. MDN’s Intl.Segmenter documentation provides locale-sensitive segmentation rather than a universal rule that every limit should count the same thing.
Write the user-facing promise
Decide whether the interface is limiting bytes, a technical string length, visible grapheme units or words. If there is a server constraint, obtain its actual contract rather than guessing from the frontend counter. Prepare harmless examples with Chinese, accented letters and a composed symbol relevant to the product. Keep the expected treatment readable. Do not let a label saying ten characters conceal a rule that surprises users when ordinary names are entered.
Choose segmentation for the intended task
MDN describes Intl.Segmenter as supporting locale-sensitive grapheme, word or sentence segmentation. Read current runtime support and choose the granularity appropriate to the stated task. Its guide explains why splitting on spaces is insufficient for languages that do not separate words that way. Keep word-count estimates distinct from a hard storage limit. If the implementation uses a fallback, define and inspect its behaviour rather than silently switching the meaning of the counter.
Inspect both the short preview and the original
For a display-only truncation, keep the full resource name available through a usable detail route and preserve the underlying source text. Check the chosen boundary and any ellipsis with the sample set. For a rejected input, make the message explain the actual limit rather than silently discarding the end. Record which examples and runtime were reviewed. A segmentation API does not decide the product rule for you; it helps implement a rule that must first be clear.