Buffer

Operators and functions for working with an array of bytes (buf type) are described here.

Operators

Operator

Result

Description

* buf

int

Returns the number of bytes in the array.

buf + buf

buf

Merges two buffers.

buf = buf

buf

Assignment operator.

buf &= buf

buf

Create a clone of the buffer. The new variable will work with the same data set.

buf += buf

buf

Appends a buffer to a buffer variable.

buf += int

buf

Appends one byte to the buffer. The number must be less than 256.

buf += str

buf

Appends a string to the buffer.

buf += char

buf

Appends a character to the buffer.

buf [ int ]

int

Sets/gets a byte by index.

Functions

buf(str s) buf

The buf function converts a string to a buf value and returns it.

str(buf b) str

The str function converts a buf value to a string and returns it.

Base64(buf b) str

The Base64 function converts a value of the buf type into a string in base64 encoding and returns it.

Del(buf b, int off, int length) buf

The Del function removes part of the data from the byte array. off is the offset of the data to be deleted, length is the number of bytes to be deleted. If length is less than zero, then the data will be deleted to the left of the specified offset. The function returns the b variable in which the deletion occurred.

Hex(buf b) str

The Hex function encodes a buf value to a hexadecimal string and returns it.

Insert(buf b, int off, buf src) buf

The Insert function inserts an array of bytes src into the array b. off is the offset where the specified byte array will be inserted. The function returns the variable b.

UnBase64(str s) buf

The UnBase64 function converts a string in base64 encoding into a value of the buf type and returns it.

UnHex(str s) buf

The UnHex function returns the buf value represented by the hexadecimal string s. The input string must contain only hexadecimal characters.