Skip to content

Main content

Encoding: Netstring Length Prefix Tool

Format a canonical netstring length prefix from an explicit UTF-8 byte count, not character count and not full framing.

Loading tool…

Description

Return its decimal spelling followed by a colon as prefix.

Length-prefixed and delimiter-framed encodings depend on precise counts and canonical token spelling. Text characters and encoded byte lengths can differ, so a supplied numeric length is not verification of the payload.

Return its decimal spelling followed by a colon as prefix.

When to use this tool

Use Encoding: Netstring Length Prefix when assembling one explicit length or canonical integer token.

How to use the tool and how it works

  1. Enter utf8ByteLength. 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 whole utf8ByteLength in [0,1000000000]. Return its decimal spelling followed by a colon as prefix.1

Input fieldMeaning and unitsAccepted input
utf8ByteLengthSupplied payload UTF-8 byte length, not a character count.Required. Safe integer.
Output fieldInterpretationReturned shape
resultObject containing the named calculated members below.Required. Object.
result.prefixPrefixCalculated result member: string.
json
{
  "input": {
    "utf8ByteLength": 12
  },
  "output": {
    "result": {
      "prefix": "12:"
    }
  }
}

Limitations and assumptions

  • The byte length is supplied, not measured from text. A complete netstring also needs the actual bytes and trailing comma; characters and UTF-8 bytes must not be confused.
  • 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 complete parser or serializer to verify the actual payload, delimiters and container structure.

References

  1. Calculation and input contract: encode/netstring-length-prefix — tool.io

Similar or alternative tools