to-buffer
Syntax
- to-buffer: spec
The spec is a string that can include:
- type: One of
uint8,int8,uint16,int16,uint32,int32,uint64,int64,float32,float64,double,string. Default isuint8. - order: Byte order
be(big-endian) orle(little-endian). Default isbe.
Examples: uint16, type=float32 order=le, string.
Description
The to-buffer operation converts the input value into a binary buffer and forwards it. It is the inverse of from-buffer. Input can be a number, string, or buffer; for string type the value is written as UTF-8. If the input is an array of values (or buffers), they are concatenated into a single buffer.
Use to-buffer when you need to produce binary data for a downstream operation (for example from-buffer with a different layout, or a device that consumes buffers).
Examples
- AdapterScript
encoded:
- source: some-value
- to-buffer: uint16
floats-le:
- source: [1.0, 2.0]
- to-buffer: type=float32 order=le