Encodings
Decimal
Every byte as a plain number from 0 to 255. The ASCII table you already know. Spaced by default
Encoding / Decimal
Decimal
A number a byte. The ASCII table, written out.
- Overhead
- +156% on random bytes
- Padding
- none
- Standard
- Byte values in base 10
- Family
- 1 in decimal
family 1 / 21
Sample
- Out
- 104 101 108 108 111 32 119 111 114 108 100 33
- Back
- "hello world!"
0123456789
Options
Access
- Import
import { decimal } from "@agntn/encodings/decimal" - CLI
encodings encode decimal 'hello world!' - Tryplayground with the sample above
The ASCII table, written out. 72 is H, 105 is i. You've seen it a hundred times.
encode("decimal", "Hi"); // "72 105"
encode("decimal", "Hi", { separate: false }); // "072105"
Spaces or commas between numbers, both read the same. Without any separator, decimal can't tell 1 2 from 12. So separate: false pads every byte to three digits, and decoding reads a run three at a time. Four digits in a row? That's an error, not a guess.
Anything over 255 doesn't fit a byte, and you get the index of it.