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
- Enter lexeme. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- 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 field | Meaning and units | Accepted input |
|---|---|---|
| lexeme | JSON text containing one string value; escaped Unicode sequences are decoded before scanning. | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| unpaired | Unpaired | Required. Boolean. |
| codeUnitCount | Code Unit Count | Required. Safe integer. |
{
"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
Similar or alternative tools
- JSON Property Key Surrogate Escape Check
Parse lexeme as a string and scan UTF-16 surrogate pairing.
- JSON String Utf16 Pair Assembly
Combine the pair as 65536 + (high - 55296) × 1024 + low - 56320 and return scalar and text.