Description
Classify a numeric UTF-16 code unit.
Unicode code points, UTF-16 units and UTF-8 octets are different representations. A local escape or byte check can report useful structure without establishing that an entire encoded string is well formed.
Classify a numeric UTF-16 code unit.
When to use this tool
Use Utf16 Lone Surrogate Token Label when inspecting the stated scalar, escape or byte-layout component.
How to use the tool and how it works
- Enter codeUnit. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read kind, scalar. Inspect scalar before interpreting the associated values.
Classify a numeric UTF-16 code unit. Require whole codeUnit in [0,65535]; return high-surrogate, low-surrogate or non-surrogate, and scalar false for either surrogate category.1
Unicode scalar values exclude surrogate code points. Code units, scalar values and encoded byte sequences are distinct representations.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| codeUnit | One numeric UTF-16 code unit; a surrogate is not a Unicode scalar value. | Required. Safe integer; minimum 0; maximum 65535. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| kind | Kind | Required. Text; maximum UTF-16 length 8192. |
| scalar | False for high or low surrogates; true for the other single UTF-16 code units. | Required. Boolean. |
{
"input": {
"codeUnit": 55296
},
"output": {
"kind": "high-surrogate",
"scalar": false
}
} Limitations and assumptions
- A lone surrogate is not a scalar; no neighboring units or encoded string are inspected.
- 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 a conforming complete decoder for strings and distinguish Unicode scalar validity from source-language or HTML error recovery.
References
-
Calculation and input contract: decode/utf16-lone-surrogate-token-label — tool.io
-
Unicode 17.0: conformance and encoding forms — Unicode Consortium
Similar or alternative tools
- Decoding: Utf16 Surrogate Pair Scalar
Decode an ordered UTF-16 surrogate pair to a scalar.
- Decoding: UTF-8 Continuation Payload Bits
Extract one UTF-8 continuation octet's six payload bits.