stdbytes - anssihalmeaho/funl GitHub Wiki

stdbytes

Provides services to use data as byte sequence.

bytearray (opaque type)

Opaque type bytearray represents byte sequence data.

nl value

Newline value as bytearray.

stdbytes.nl

Functions

new

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

string

Converts bytearray to string. Argument is bytearray.

type: function

Format:

call(stdbytes.string <bytearray>) -> <string>

Return value: string

str-to-bytes

Converts string to bytearray. Argument is string.

type: function

Format:

call(stdbytes.str-to-bytes <string>) -> <bytearray>

Return value: bytearray

count

Returns number of bytes in bytearray. Argument is bytearray.

type: function

Format:

call(stdbytes.count <bytearray>) -> <int>

Return value: int

as-list

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)

split-by

Returns list of bytearrays which are result of split operation for bytearray given as 1st argument.

Arguments:

  1. bytearray to be splitted
  2. 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)))
⚠️ **GitHub.com Fallback** ⚠️