Skip to content

Main content

JSON String Utf16 Codeunit Escape Tool

Compute json string utf16 codeunit escape from explicit bounded inputs.

Loading tool…

Description

Format codeUnit in 0-65535 as a lowercase four-digit JSON Unicode escape.

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.

Format codeUnit in 0-65535 as a lowercase four-digit JSON Unicode escape.

When to use this tool

Use JSON String Utf16 Codeunit Escape when you need a decoded UTF-16 or normalization diagnostic.

How to use the tool and how it works

  1. Enter codeUnit. 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 escape, surrogate. Inspect surrogate before interpreting the associated values.

Format codeUnit in 0-65535 as a lowercase four-digit JSON Unicode escape. Flag units in the surrogate range.1

Input fieldMeaning and unitsAccepted input
codeUnitCode UnitRequired. Safe integer; minimum 0; maximum 65535.
Output fieldInterpretationReturned shape
escapeEscapeRequired. Text; maximum UTF-16 length 8192.
surrogateSurrogateRequired. Boolean.
json
{
  "input": {
    "codeUnit": 65
  },
  "output": {
    "escape": "\\u0041",
    "surrogate": false
  }
}

Limitations and assumptions

  • A surrogate escape represents a code unit and may need a second escape for a Unicode scalar; the tool does not build a pair.
  • 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 Unicode-aware text processing and a full JSON parser when decoding, comparing, or repairing complete documents.

References

  1. Calculation and input contract: json/json-string-utf16-codeunit-escape — tool.io

Similar or alternative tools