Home > lang > datarep 
 en fr de es it nl pt pt_BR mk sq ca hu cs tr ar fa id vi ko ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
Documentation  
Warning! This page is not translated.  See english version 
Binary Data Representation
The READ and WRITE instructions allow to read and write binary representation of Gambas datatypes values.

Datatype Size Representation
Boolean 1 byte 0 for FALSE, 255 for TRUE.
Byte 1 byte The data value in binary.
Short 2 bytes The data value in binary.
Integer 4 bytes The data value in binary.
Long 8 bytes The data value in binary.
Pointer 4 bytes in 32 bits
8 bytes in 64 bits
The pointer value in binary.
Single 4 bytes The data value in binary.
Float 8 bytes The data value in binary.
Date 8 bytes The date and time as two four-bytes integers.
String variable The string length is written first, as a variable-length integer number:
  • One byte is written if the string length is lower or equal than 127 characters.
  • Two bytes are written if the string length is between 128 and 16383 characters.
  • Four bytes are written if the string length is between 16384 and 1073741824 characters.
  • Longer strings cannot be written at the moment.
Then the string contents is written.
NULL 1 byte Null values and null strings are written as a single 0 byte.
Variant Variable When writing a variant value, a byte indicating the value datatype is written before. The value itself is written according to this table.
Array 2 bytes + array length + array contents
  • One byte whose value is 65.
  • One byte whose value represents the array contents datatype.
  • The array length, written like a string length.
  • The value of each array element.
Collection 1 byte + collection length + collection contents
  • One byte whose value is 67 if the collection keys are case sensitive, 99 if they are not case sensitive.
  • The collection length, written like a string length.
  • For each collection item:
    • The key, written as a string
    • Its associated value.
Structure Contents size
  • The structure contents are written in declaration order recursively.
  • Embedded arrays items are written in order. Contrary to normal arrays, no size or type header is written.

The endianness of the binary data is the endianness of the stream.

See also

READ, WRITE, ByteOrder