Skip to content

Main content

Decoding: Utf16 Surrogate Pair Scalar Tool

Decode one validated UTF-16 surrogate pair to its Unicode scalar, rejecting isolated or reversed halves.

Loading tool…

Description

Decode an ordered UTF-16 surrogate pair to a scalar.

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.

Decode an ordered UTF-16 surrogate pair to a scalar.

When to use this tool

Use Decoding: Utf16 Surrogate Pair Scalar when inspecting the stated scalar, escape or byte-layout component.

How to use the tool and how it works

  1. Enter highSurrogate, lowSurrogate. 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 result. Expand result to inspect the returned fields.

Decode an ordered UTF-16 surrogate pair to a scalar. Require highSurrogate in D800-DBFF and lowSurrogate in DC00-DFFF; combine offsets as 65536+(high-D800)*1024+(low-DC00).1

Unicode scalar values exclude surrogate code points. Code units, scalar values and encoded byte sequences are distinct representations.2

Input fieldMeaning and unitsAccepted input
highSurrogateHigh SurrogateRequired. Safe integer.
lowSurrogateLow SurrogateRequired. Safe integer.
Output fieldInterpretationReturned shape
resultReturned object; expand its named members below.Required. Object.
result.codepointNumeric Unicode code point; distinguish code points from UTF-16 code units.Calculated result member: number.
json
{
  "input": {
    "highSurrogate": 55357,
    "lowSurrogate": 56832
  },
  "output": {
    "result": {
      "codepoint": 128512
    }
  }
}

Limitations and assumptions

  • Inputs are numeric code units, not endian-specific bytes or literal escape strings.
  • Outputs are nested inside result. 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

  1. Calculation and input contract: decode/utf16-surrogate-pair-scalar — tool.io

  2. Unicode 17.0: conformance and encoding forms — Unicode Consortium

Similar or alternative tools