Convert text offsets between UTF-16, code points, UTF-8 bytes and graphemes, and locate hidden Unicode

$0.005 USDC per call · Agent infrastructure · POST /api/v1/text-offsets · Id text-offsets

Reports the length of a string in UTF-16 code units, Unicode code points, UTF-8 bytes and extended grapheme clusters (Intl.Segmenter), converts up to 200 ranges given in any one of those units into all four, and flags ranges that fall inside a surrogate pair, a multi-byte UTF-8 character or a grapheme cluster. It also runs the unicode-check rules (bidi controls, zero-width and invisible characters, tag characters, confusables) and returns each finding's offsets in all four systems, plus line-ending, BOM, normalization-form (NFC/NFD) and unpaired-surrogate facts. Grapheme boundaries follow the ICU version of this runtime. Does not decode bytes or fix text.

What you get

Offsets that agree between a JS model, a Rust tool and a byte-based API. 50,000 characters per $0.005 call.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/text-offsets. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/text-offsets \
  -H 'content-type: application/json' \
  -d '{"text":"naïve 👨‍👩‍👧 ‮evil","ranges":[{"unit":"grapheme","start":6,"end":7},{"unit":"utf8","start":6,"end":8}]}'

Input

FieldTypeRequiredDescription
textstring; length 0..50000yesThe string.
rangesarray<object>; max 200 itemsnoHalf-open ranges to convert; each is read in its own unit.
kindstring; one of "text", "identifier", "url"noHow the unicode rules treat the string. Default text.
scanbooleannoRun the hidden-Unicode rules. Default true.

Example request body

{
  "text": "naïve 👨‍👩‍👧 ‮evil",
  "ranges": [
    {
      "unit": "grapheme",
      "start": 6,
      "end": 7
    },
    {
      "unit": "utf8",
      "start": 6,
      "end": 8
    }
  ]
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
lengthsobjectno
propertiesobjectno
rangesarray<object>; max 200 itemsno
unicodeobjectno
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the context-evidence-kit package.

Machine-readable