Skip to content

Main content

JSON Unpaired Surrogate Lexeme Flag Tool

Compute json unpaired surrogate lexeme flag from explicit bounded inputs.

Loading tool…

Description

Parse lexeme as a JSON string and scan its UTF-16 units.

JSON strings use escape syntax, while decoded JavaScript strings are sequences of UTF-16 units. A supplementary Unicode scalar occupies a surrogate pair, and a lone surrogate is not a complete scalar.

Parse lexeme as a JSON string and scan its UTF-16 units.

When to use this tool

Use JSON Unpaired Surrogate Lexeme Flag when you need a decoded UTF-16 or normalization diagnostic.

How to use the tool and how it works

  1. Enter lexeme. 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 unpaired, codeUnitCount. Inspect unpaired before interpreting the associated values.

Parse lexeme as a JSON string and scan its UTF-16 units. Pair high surrogates with following low surrogates and flag any unmatched high or low unit; return codeUnitCount.1

JSON escape grammar can admit a lone surrogate even though it does not represent a complete Unicode character. Interoperability therefore requires more than checking that a string token parses.2

Input fieldMeaning and unitsAccepted input
lexemeJSON text containing one string value; escaped Unicode sequences are decoded before scanning.Required. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
unpairedUnpairedRequired. Boolean.
codeUnitCountCode Unit CountRequired. Safe integer.
json
{
  "input": {
    "lexeme": "\"\\ud800\""
  },
  "output": {
    "unpaired": true,
    "codeUnitCount": 1
  }
}

Limitations and assumptions

  • The parser may accept lone surrogate escapes; unpaired reports that condition without repairing the string or counting graphemes.
  • 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.

Alternative or Complementary methods

Use Unicode-aware text processing and a full JSON parser when decoding, comparing, or repairing complete documents.

References

  1. Calculation and input contract: json/json-unpaired-surrogate-lexeme-flag — tool.io

  2. The JavaScript Object Notation (JSON) Data Interchange Format (RFC 8259) — RFC Editor / IETF

Similar or alternative tools