Text Truncate Tool

MaximumTOTALcodepointlimitincludescaller suffix;not UTF16substring or grapheme/displaywidth preservation. Explicitboundedofflineconvention,not authoritative external identity,eligibility,clinical or safe-use determination.

Description

Unicode code points and visible characters are different counting units.

Unicode code points and visible characters are different counting units.1

This truncator caps the total code-point count including a caller-supplied suffix, which can still split a grapheme cluster.

When to use Text Truncate Tool

Use this tool to apply the stated text truncate tool operation with an explicit input and unit basis.

How to use Text Truncate Tool and how it works

  1. Establish the text or game convention described above.
  2. Enter actualText, actualCodepointLimit, actualSuffix and run the tool.
  3. Read result.truncatedText, result.wasTruncated using the output meanings below.
  4. If input is rejected, correct the stated type, range, ordering or alignment issue and rerun; review successful results under the declared convention.
Input fieldMeaningValue typeRequirement
actualTextText, on the basis specified in the algorithm.stringrequired; further conditions in the algorithm
actualCodepointLimitCodepoint limit, on the basis specified in the algorithm.numberrequired; finite; integer from 0 to 1000000; further conditions in the algorithm
actualSuffixSuffix, on the basis specified in the algorithm.stringrequired; further conditions in the algorithm

Require integer limit 0–1,000,000. Return original text if it fits; otherwise require suffix to fit, keep limit minus suffix-length code points and append the suffix.

truncated = first(limit − suffix code points) + suffix

Apply the declared units, ordering and branch conditions.

Output fieldMeaningValue type
resultObject containing the declared output fields.object
result.truncatedTextOriginal or shortened text under the total code-point limit.string
result.wasTruncatedTrue only when the original code-point count exceeded the limit.boolean
json
{
  "input": {
    "actualText": "A🌙BCD",
    "actualCodepointLimit": 3,
    "actualSuffix": "…"
  },
  "output": {
    "result": {
      "truncatedText": "A🌙…",
      "wasTruncated": true
    }
  }
}

Limitations and assumptions

The output applies the declared operation to the values you supply. Establish the measurement basis, units, coefficients and any caller-selected rules before interpreting it. The tool does not independently collect or verify observations or decide whether a model or reference applies.

Supply explicit required fields with the documented types and dense aligned arrays. Unknown fields, wrong types and nonfinite numbers are rejected. Branch-specific constraints are explained above. A successful false boolean, negative signed difference, empty slice or unresolved tie is distinct from an input error. Very large inputs or outputs may be rejected by shared resource limits.

Alternative or Complementary methods

For a related operation, use Title Case Converter. Simple title casing capitalizes each ASCII letter run and lowercases its remaining letters.

For a related operation, use Nickname Shortener Fun. A short nickname can be formed as a prefix of a supplied name.

References

  1. Text Truncate Tool — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies