Skip to content

Main content

Search Snippet Highlight Offset Pair Tool

Split a supplied search snippet at explicit half-open Unicode code-point offsets, returning plain text segments without markup.

Loading tool…

Description

Split a search snippet at supplied code-point highlight offsets.

Information records distinguish identifiers, controlled vocabularies, language fallbacks, assertion times and valid times. A supplied inverse predicate differs from an inferred semantic relation. Text offsets require an explicit code-point or code-unit basis, and a metadata count check does not validate field content or an entire schema.

Split a search snippet at supplied code-point highlight offsets.

When to use this tool

Use Search Snippet Highlight Offset Pair when you already have snippetText, startCodePoint, endCodePoint and need to split a search snippet at supplied code-point highlight offsets.

How to use the tool and how it works

  1. Enter snippetText, startCodePoint, endCodePoint. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read before, highlighted, after. Use the output convention below.

Require safe whole 0<=start<=end<=Array.from(text).length; slice the code-point array into before, highlighted [start,end) and after, then rejoin.1

Supplementary code points occupy two UTF-16 code units. Code-point slicing also differs from grapheme segmentation, so a highlight boundary can split a user-perceived character.2

Input fieldMeaning and unitsAccepted input
snippetTextSnippet TextRequired. Text; maximum UTF-16 length 8192.
startCodePointZero-based Array.from offset, inclusive; differs from a UTF-16 code-unit offset.Required. Safe integer; minimum 0.
endCodePointExclusive code-point end; no grapheme segmentation or HTML markup is generated.Required. Safe integer.
Output fieldInterpretationReturned shape
beforeBeforeRequired. Text; maximum UTF-16 length 8192.
highlightedHighlightedRequired. Text; maximum UTF-16 length 8192.
afterAfterRequired. Text; maximum UTF-16 length 8192.
json
{
  "input": {
    "snippetText": "Hello world",
    "startCodePoint": 6,
    "endCodePoint": 11
  },
  "output": {
    "before": "Hello ",
    "highlighted": "world",
    "after": ""
  }
}

Limitations and assumptions

  • Offsets are code points, not UTF-16 code units, graphemes or rendered width. The helper does not generate HTML or check highlight relevance.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use the actual record, vocabulary authority and complete metadata schema for semantic or conformance questions. Apply the identifier scheme's real comparison rules and the intended language/offset policy rather than inferring them from a local string operation.

References

  1. Calculation and input contract: information-science/search-snippet-highlight-offset-pair — tool.io

  2. Unicode 17.0: characters and encoding forms — Unicode Consortium

Similar or alternative tools