Skip to content

Main content

Base N Fixed Width Left Padding Count Tool

Compute base n fixed width left padding count from explicit bounded inputs.

Loading tool…

Description

Pad encoded text to a supplied code-point width with an explicit one-code-point zero symbol.

A positional encoding separates numeric digit values, alphabet symbols and final-block padding. An alphabet lookup is not a whole-stream codec, and character count can differ from the number of source bytes represented.

Pad encoded text to a supplied code-point width with an explicit one-code-point zero symbol.

When to use this tool

Use Base N Fixed Width Left Padding Count when checking one alphabet mapping or bounded encoding-padding term.

How to use the tool and how it works

  1. Enter encoded, width, zeroSymbol. 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 padded, added. Use the output convention below.

Require whole width in [0,256], zeroSymbol containing exactly one Unicode code point and encoded having at most width code points. added = width-codePointLength(encoded); padded prepends that many zeroSymbol repetitions.1

Input fieldMeaning and unitsAccepted input
encodedEncodedRequired. Text; maximum UTF-16 length 8192.
widthTarget length in Unicode code points, zero through 256.Required. Safe integer; minimum 0; maximum 256.
zeroSymbolExactly one Unicode code point used for literal left padding.Required. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
paddedPaddedRequired. Text; maximum UTF-16 length 8192.
addedAddedRequired. Safe integer.
json
{
  "input": {
    "encoded": "abc",
    "width": 5,
    "zeroSymbol": "0"
  },
  "output": {
    "padded": "00abc",
    "added": 2
  }
}

Limitations and assumptions

  • No alphabet or numeric equivalence is checked. Code-point width is not grapheme or display-cell width, and arbitrary padding may change an encoding's meaning.
  • 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 the complete codec matching the intended alphabet and padding policy for real payloads and interoperability checks.

References

  1. Calculation and input contract: encode/base-n-fixed-width-left-padding-count — tool.io

Similar or alternative tools