https://github.com/lordnull/erlnetstr
Module for wrapping and unwrapping binaries in netstring format.
https://github.com/lordnull/erlnetstr
Last synced: 9 months ago
JSON representation
Module for wrapping and unwrapping binaries in netstring format.
- Host: GitHub
- URL: https://github.com/lordnull/erlnetstr
- Owner: lordnull
- License: mit
- Created: 2011-11-28T04:04:32.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2017-10-28T23:31:52.000Z (over 8 years ago)
- Last Synced: 2025-01-28T01:36:43.138Z (over 1 year ago)
- Language: Erlang
- Homepage:
- Size: 156 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- License: LICENSE
Awesome Lists containing this project
README
Installation / Including
========================
Include as one would any other erlang application. It's a simple library
style, so there is nothing to start. Uses erlang.mk so anything with a
`make` file should be able to integrate this fine.
Encoding
========
Pass and `iolist()` to one of the two encode functions. `encode/1` uses the
standard radix of 10. Both return an `iolist()`.
Decoding
========
Decoding is a bit more complex due to the nature of streams of binaries.
`decode/1` will get one started, but unless you are guaranteed
to always get one string at a time, is of limited use.
Use `decode/2`, passing in the initial binary chunk of the stream,
and the radix to decode the stream. The result is a tuple:
`{[binary()], #continuation{}}`
For the next `decode/2` call, use the `#continuation{}`
as the second argument. Each successive call to `decode/2`
should use the `#continuation{}` that was returned from the
previous `decode`.