Description
Parse a canonical netstring length-prefix token.
Binary and text framing can encode a payload size, container count or terminator. Those fields describe the following data but must still be checked against its actual bytes and complete structure.
Parse a canonical netstring length-prefix token.
When to use this tool
Use Netstring Length Prefix Token when decoding one bounded framing or header component.
How to use the tool and how it works
- Enter token. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read length. Use the output convention below.
Parse a canonical netstring length-prefix token. Require zero or a nonzero-leading decimal integer followed by a colon; length must be a nonnegative safe integer.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| token | Token | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| length | Declared byte length only; no payload or trailing comma is checked. | Required. Safe integer. |
json
{
"input": {
"token": "12:"
},
"output": {
"length": 12
}
} Limitations and assumptions
- No payload or trailing comma is checked, and leading-zero lengths are rejected.
- 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.
Alternative or Complementary methods
Use a complete parser for payload validity, nested containers, text encoding and record boundaries.
References
Similar or alternative tools
- Decoding: UTF-8 Leading Byte Sequence Length
Inspect a UTF-8 lead octet's expected sequence length.
- BER Length Short Long Discriminator
Classify an initial BER length octet.