Skip to content

Main content

UTF-8 Codepoint Byte Budget Tool

Return the UTF-8 byte length of one Unicode scalar value; surrogate code points are rejected.

Loading tool…

Description

Validate codePoint as a Unicode scalar and return one, two, three, or four UTF-8 bytes at the 0x7F, 0x7FF, and 0xFFFF boundaries.

Unicode text can be counted as code points, UTF-16 units, encoded bytes, or grapheme clusters. A literal character transformation follows a specific mapping and may preserve distinctions that a broader normalization would remove.

Validate codePoint as a Unicode scalar and return one, two, three, or four UTF-8 bytes at the 0x7F, 0x7FF, and 0xFFFF boundaries.

When to use this tool

Use UTF-8 Codepoint Byte Budget when you need one explicitly bounded Unicode mapping, count, or encoding component.

How to use the tool and how it works

  1. Enter codePoint. 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 byteCount. Use the output convention below.

Validate codePoint as a Unicode scalar and return one, two, three, or four UTF-8 bytes at the 0x7F, 0x7FF, and 0xFFFF boundaries.1

UTF-8 encodes a Unicode scalar in one through four bytes. Surrogate code points are excluded, so they cannot be treated as individually encodable Unicode scalars.2

Input fieldMeaning and unitsAccepted input
codePointInteger Unicode scalar from U+0000 to U+10FFFF, excluding U+D800-U+DFFF.Required. Safe integer.
Output fieldInterpretationReturned shape
byteCountUTF-8 bytes for this one scalar; not a grapheme count or UTF-16 length.Required. Safe integer.
json
{
  "input": {
    "codePoint": 128578
  },
  "output": {
    "byteCount": 4
  }
}

Limitations and assumptions

  • Surrogate code points are rejected; the count covers one scalar rather than a grapheme, complete string, or BOM.
  • 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

Choose normalization and comparison rules for the intended language and preserve the original text when creating a search variant.

References

  1. Calculation and input contract: text/utf8-codepoint-byte-budget — tool.io

  2. UTF-8, a transformation format of ISO 10646, RFC 3629 — RFC Editor / IETF

Similar or alternative tools