diff options
author | Profpatsch <mail@profpatsch.de> | 2021-01-23T15·32+0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2021-01-23T15·33+0000 |
commit | 222016a174ba08842d3c80cede846c284c7cb035 (patch) | |
tree | a5b26d6cebf677a6e2cbc8169e7ab304a7f8dfb3 | |
parent | cc3f54a0eedb579c2ffd76f0505af0ccf940f9ff (diff) |
feat(users/Profpatsch/netstring): add README r/2138
Change-Id: I2b5e74f376ac2212ec12fd85267e115621095639 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2432 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
-rw-r--r-- | users/Profpatsch/netstring/README.md | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/users/Profpatsch/netstring/README.md b/users/Profpatsch/netstring/README.md new file mode 100644 index 000000000000..4413d88ee430 --- /dev/null +++ b/users/Profpatsch/netstring/README.md @@ -0,0 +1,18 @@ +# Netstring + +Netstrings are a djb invention. They are intended as a serialization format. Instead of inline control characters like `\n` or `\0` to signal the end of a string, they use a run-length encoding given as the number of bytes, encoded in ASCII, at the beginning of the string. + +``` +hello -> 5:hello, +foo! -> 4:foo!, +こんにちは -> 15:こんにちは, +``` + +They can be used to encode e.g. lists by simply concatenating and reading them in one-by-one. + +If you need a more complex encoding, you could start encoding e.g. tuples as netstrings-in-netstrings, or you could use [`netencode`](../netcencode/spec.md) instead, which is what-if-json-but-netstrings, and takes the idea of netstrings to their logical conclusion. + +Resources: + +Spec: http://cr.yp.to/proto/netstrings.txt +Wiki: https://en.wikipedia.org/wiki/Netstring |