Skip to content

Main content

Utf16 Non Bmp Escape Pair Tool

Compute utf16 non bmp escape pair from explicit bounded inputs.

Loading tool…

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

  1. Enter point. 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 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 fieldMeaning and unitsAccepted input
pointSupplementary Unicode scalar integer from U+10000 through U+10FFFF.Required. Safe integer; minimum 65536.
Output fieldInterpretationReturned shape
highHighRequired. Safe integer.
lowLowRequired. Safe integer.
escapesTwo literal lowercase four-digit UTF-16 backslash-u escapes.Required. Text; maximum UTF-16 length 8192.
json
{
  "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

  1. Calculation and input contract: encode/utf16-non-bmp-escape-pair — tool.io

  2. The Unicode Standard: core definitions and UTF-16 — Unicode Consortium

Similar or alternative tools