Description
Return a supplementary scalar’s UTF-16 surrogate values and literal paired escape spelling.
Unicode scalar values are distinct from UTF-8 bytes and UTF-16 code units. One scalar can require several units, and printable escape text is a representation of those values rather than execution or normalization of a string.
Return a supplementary scalar’s UTF-16 surrogate values and literal paired escape spelling.
When to use this tool
Use Utf16 Non Bmp Escape Pair when inspecting one scalar, code-unit layout or literal escape representation.
How to use the tool and how it works
- Enter point. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read high, low, escapes. Use the output convention below.
Require whole point in [65536,1114111]. Let u = point-65536, high = 0xD800+(u>>10), low = 0xDC00+(u&1023). Return both code units and their consecutive lowercase four-digit backslash-u escape spellings.1
UTF-16 distinguishes scalar values from code units and represents supplementary scalars with a surrogate pair. Literal escape text is a separate representation.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| point | Supplementary Unicode scalar integer from U+10000 through U+10FFFF. | Required. Safe integer; minimum 65536. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| high | High | Required. Safe integer. |
| low | Low | Required. Safe integer. |
| escapes | Two literal lowercase four-digit UTF-16 backslash-u escapes. | Required. Text; maximum UTF-16 length 8192. |
{
"input": {
"point": 128512
},
"output": {
"high": 55357,
"low": 56832,
"escapes": "\\ud83d\\ude00"
}
} Limitations and assumptions
- Only supplementary-plane scalars are accepted. The escape text describes UTF-16 code units, not UTF-8 bytes or a literal source-code execution.
- 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 full Unicode encoder or parser when processing strings, and handle normalization, graphemes and context-specific escaping separately.
References
-
Calculation and input contract: encode/utf16-non-bmp-escape-pair — tool.io
-
The Unicode Standard: core definitions and UTF-16 — Unicode Consortium
Similar or alternative tools
- Encoding: Utf16 Surrogate Pair Codepoint
Encode one Unicode scalar as one UTF-16 code unit or an ordered surrogate pair.
- UTF-8 BOM Octet Triplet
Return octets [239,187,191] when include is true and an empty array otherwise.