Libraries anvil lang binary

class binary
extends anvil.lang.sequence
Binary is an efficient implemtation of variable length array of bytes.

Constructor
binary binary(range dimension)
binary binary(string data)
binary binary(buffer data)
binary binary(object data, ...)
Creates and returns efficient array of bytes. Indexing of binary always starts from zero.
Parameters dimension -  Length of array as range (e.g. ..100).
data -  Datas to initialize array with


Methods

string decodeFrom(string encoding)
Decodes this binary to string using given character encoding, throws IOError if binary cannot be mapped
string decodeFrom(string encoding, string replacement)
Decodes this binary to string using given character encoding, unmappable characters are replaced with given string
string decodeFrom(string encoding, null ignore)
Decodes this binary to string using given character encoding, unmappable characters are ignored.
Throws BadParameter -  if given character encoding is unsupported, or replacement is invalid
IOError -  if some bytes are unmappable and no replacement given

string toHex()
Converts contents of this binary to hexadecimal representation.

int toInt(width)
int toInt(width, offset)
Converts the contents of binary at given offset to integer of given byte width. If width is negative the byteorder is reversed. Maximum width is eight (8). If offset is omitted zero (0) is used instead.

object unserialize()
Unserializes the serialized data contained in this binary.
Throws CorruptedSerialization -  If serialization is corrupted