Text slice codepoints
text-slice-codepoints · version 1.0.0 · Text · free, no key needed
Slice a string by Unicode code-point indexes, not UTF-16 code units.
Use when you need to: text slice codepoints · slice text by unicode code points · code point substring.
Decide before calling
Read the versioned contract and the supported scope below. Reuse text-slice-codepoints@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use text-slice-codepoints@1.0.0 for text slice codepoints. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- text slice codepoints
- slice text by unicode code points
- code point substring
Not supported
- UTF-16 code-unit slicing
- grapheme cluster slicing
- negative indexes
- python wrap-around slicing
- byte-offset slicing
- read files
Behavior
- text is a UTF-8 bounded string of at most 250 KiB.
- start and length are JSON integers >= 0. Negative indexes and wrap-around are rejected.
- Indexes count Unicode code points as in Array.from(text), not UTF-16 units and not grapheme clusters.
- If start is greater than the code-point count, or start + length is greater than the code-point count, the tool throws slice out of range.
- A zero-length slice at start equal to the code-point count is allowed and returns an empty string.
- No Unicode normalization or case folding is applied.
Input
text(string, required): max length 256000start(integer, required): min 0length(integer, required): min 0
Output
text(string, required): max length 256000
Limits
- max text bytes: 256000
Example
Request input:
{
"text": "hello",
"start": 1,
"length": 3
}
Response:
{
"result": {
"text": "ell"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "text-slice-codepoints",
"version": "1.0.0",
"input": {
"text": "hello",
"start": 1,
"length": 3
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/text-slice-codepoints/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"text":"hello","start":1,"length":3}'
The machine-readable contract is at /v1/tools/text-slice-codepoints/versions/1.0.0.
CLI
node cli.mjs run text-slice-codepoints 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Text wrap width: Hard-wrap text by Unicode code-point width and return the resulting lines.
- Citation anchor check: Check a quote anchor (exact text plus prefix/suffix) matches exactly one place in a supplied source version.
- Text count: Count Unicode code points, UTF-16 code units, UTF-8 bytes, and lines.
- Text levenshtein distance: Compute bounded Levenshtein distance over code points or deterministic grapheme tokens.
- Text run length decode: Decode canonical count:HEX; run-length text and return the expanded Unicode string.
- Text sentence offsets: Return UAX #29 sentence spans as start/end offsets in code points, UTF-16 units or UTF-8 bytes, with the ending rule.