Skip to content

Main content

Terminal Escape Token Incomplete Tail Finder

Find the first incomplete ESC/CSI/OSC lexical token tail under the documented seven-bit scanner; no terminal emulation or UTF-8 byte-stream decoding.

Loading tool…

Description

Find the first incomplete ESC/CSI/OSC lexical token tail under the documented seven-bit scanner; no terminal emulation or UTF-8 byte-stream decoding.

Terminal escape sequences can encode cursor commands, text styles and other controls inside ordinary text. SGR changes selected graphic attributes; CSI and OSC tokens have different framing. These tools operate on explicit strings and records, with a deliberately limited parser or style model rather than an emulated screen.1

Find the first incomplete ESC/CSI/OSC lexical token tail under the documented seven-bit scanner; no terminal emulation or UTF-8 byte-stream decoding.

When to use this tool

Use this tool to find the first incomplete ESC/CSI/OSC lexical token tail under the documented seven-bit scanner; no terminal emulation or UTF-8 byte-stream decoding.

How to use the tool and how it works

  1. Enter text using the field definitions below.
  2. Run the operation. Correct input errors before interpreting an output.
  3. Read result.tail. Use the ordering, boundary rules and absence conditions described below.

Run the escape tokenizer and return its first incomplete token record, including its UTF-16 span, or null when no incomplete token exists.2

Input fieldMeaning and unitsAccepted input
textSource text or visible text, including actual escape characters where the operation inspects them.Text, at most 8,192 UTF-16 code units; the operation’s grammar also applies.
Output fieldInterpretation
resultObject containing the named fields below.
result.tailFirst incomplete recognized escape-token record, or null if none exists.
json
{
  "input": {
    "text": "x\u001b[31"
  },
  "output": {
    "result": {
      "tail": {
        "start": 1,
        "end": 5,
        "type": "CSI",
        "text": "\u001b[31",
        "complete": false
      }
    }
  }
}

Limitations and assumptions

  • A null result does not prove that the text is safe or that every escape sequence is semantically supported.
  • Source spans use zero-based UTF-16 offsets with exclusive ends; byte totals, where returned, use UTF-8. Escape tokens are represented as JSON escapes in the example and are not executed by this description.
  • Every declared top-level input field is required and unexpected fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and no larger in absolute magnitude than the safe-integer limit; operations returning exact large integers use decimal text. Positions are zero-based and spans end exclusively unless the operation explicitly states a different convention.

Alternative or Complementary methods

Use token inspection for source offsets and style replay for the supported attributes. A real terminal emulator is needed to determine screen contents, terminal-specific rendering or device behavior.

References

  1. ECMA-48: Control Functions for Coded Character Sets — Ecma International

  2. Tool behavior and example: Terminal Escape Token Incomplete Tail Finder — tool.io

Similar or alternative tools

  • Terminal Escape Token Visible Literalizer

    Literalize ASCII controls in terminal text to visible backslash-x hexadecimal spellings, preserving printable Unicode; output is diagnostic text, not a terminal sanitizer for other protocols.

  • Terminal CSI Erase Mode Token Parser

    Parse complete CSI erase-display/erase-line tokens with modes 0–2 or display-only mode 3; returns lexical evidence without terminal effects.