Description
Parse lexeme as a string, count decoded tab and space code points, and return decodedLength in 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 string, count decoded tab and space code points, and return decodedLength in UTF-16 units.
When to use this tool
Use JSON String Tab Versus Space Lexeme 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 tabs, spaces, decodedLength. Use the output convention below.
Parse lexeme as a string, count decoded tab and space code points, and return decodedLength in UTF-16 units.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| lexeme | Supplied token spelling; it is not automatically decoded text. | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| tabs | Tabs | Required. Safe integer. |
| spaces | Spaces | Required. Safe integer. |
| decodedLength | Decoded Length | Required. Safe integer. |
{
"input": {
"lexeme": "\"a\\tb c\""
},
"output": {
"tabs": 1,
"spaces": 1,
"decodedLength": 5
}
} Limitations and assumptions
- Escaped tabs count after decoding, while literal unescaped controls can make the JSON invalid; other whitespace is not counted as space.
- 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 String Utf16 Unit Count
Parse jsonString, require a string value, and return its decoded JavaScript length as utf16Units.
- JSON String Escape Length Budget
Serialize value as a JSON string and return source UTF-16 length, complete serialized length, and their difference as overhead.