# 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 256000
- `start` (integer, required): min 0
- `length` (integer, required): min 0

## Output

- `text` (string, required): max length 256000

## Limits

- max text bytes: 256000

## Example

Request input:

```json
{
  "text": "hello",
  "start": 1,
  "length": 3
}
```

Response:

```json
{
  "result": {
    "text": "ell"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "text-slice-codepoints",
  "version": "1.0.0",
  "input": {
    "text": "hello",
    "start": 1,
    "length": 3
  }
}
```

### HTTP (no key)

```sh
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](/v1/tools/text-slice-codepoints/versions/1.0.0).

### CLI

```sh
node cli.mjs run text-slice-codepoints 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

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