Skip to content

Main content

Encoding: Html Numeric Reference Scalar Tool

Format one validated Unicode scalar as a terminated decimal or hexadecimal numeric character reference; no document escaping or HTML replacement policy.

Loading tool…

Description

Return a semicolon-terminated numeric character-reference spelling using decimal digits or the hexadecimal x form.

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 semicolon-terminated numeric character-reference spelling using decimal digits or the hexadecimal x form.

When to use this tool

Use Encoding: Html Numeric Reference Scalar when inspecting one scalar, code-unit layout or literal escape representation.

How to use the tool and how it works

  1. Enter codepoint, radix. 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.

Require a Unicode scalar codepoint and radix exactly 10 or 16. Return a semicolon-terminated numeric character-reference spelling using decimal digits or the hexadecimal x form.1

Input fieldMeaning and unitsAccepted input
codepointCodepointRequired. Safe integer.
radixRadixRequired. Safe integer.
Output fieldInterpretationReturned shape
resultObject containing the named calculated members below.Required. Object.
result.referenceReferenceCalculated result member: string.
json
{
  "input": {
    "codepoint": 65,
    "radix": 16
  },
  "output": {
    "result": {
      "reference": "A"
    }
  }
}

Limitations and assumptions

  • This emits reference text rather than parsing HTML. HTML's input-error recovery and special numeric-reference remappings can differ from Unicode scalar identity, particularly for zero and control values.
  • 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 full Unicode encoder or parser when processing strings, and handle normalization, graphemes and context-specific escaping separately.

References

  1. Calculation and input contract: encode/html-numeric-reference-scalar — tool.io

Similar or alternative tools