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.
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 count: Count Unicode code points, UTF-16 code units, UTF-8 bytes, and lines.
- Text extract between: Extract exact substrings between start and end markers, left to right and non-overlapping.
- Text line diff: Diff two texts as line records, preserving each line terminator.
- Text lines chunk: Split parsed lines into consecutive chunks of size lines each.
- Text NFC: Normalize Unicode text to NFC (canonical composition).
- Text NFD: Normalize Unicode text to NFD (canonical decomposition).