stdbytes - anssihalmeaho/funl GitHub Wiki
Provides services to use data as byte sequence.
Opaque type bytearray represents byte sequence data.
Newline value as bytearray.
stdbytes.nl
Creates new bytearray. List of items is given as argument. One item in list can be:
- int => value between 0-255 is interpreted as byte value
- string => string is interpreted as bytearray
- bytearray => bytes of bytearray are inserted as such
type: function
Format:
call(stdbytes.new list(<arg-1> <arg-2> ...)) -> <bytearray>
Return value: bytearray
Converts bytearray to string. Argument is bytearray.
type: function
Format:
call(stdbytes.string <bytearray>) -> <string>
Return value: string
Converts string to bytearray. Argument is string.
type: function
Format:
call(stdbytes.str-to-bytes <string>) -> <bytearray>
Return value: bytearray
Returns number of bytes in bytearray. Argument is bytearray.
type: function
Format:
call(stdbytes.count <bytearray>) -> <int>
Return value: int
Returns list of integer values where each integer value represents one byte in bytearray (given as argument).
type: function
Format:
call(stdbytes.as-list <bytearray>) -> <list>
Return value: list (of integers: value between 0-255)
Returns list of bytearrays which are result of split operation for bytearray given as 1st argument.
Arguments:
- bytearray to be splitted
- bytearray according to which splitting is done
type: function
Format:
call(stdbytes.split-by <bytearray> <bytearray>) -> <list>
Return value: list (of bytearrays)
Example:
call(stdbytes.split-by call(stdbytes.str-to-bytes '1\n 2 \n3') stdbytes.nl)
-> list(opaque(bytearray(31)), opaque(bytearray(20 32 20)), opaque(bytearray(33)))