Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Wildcard Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Bytedata Source Code
 previous   up   next 

Types
signedness
Enumeration of signedness values.
endianess
Enumeration of endianess values.

signedness

const type: signedness

Enumeration of signedness values. Signedness defines if negative values can be represented. Defines: UNSIGNED and SIGNED. Signed values use the twos-complement representation.


endianess

const type: endianess

Enumeration of endianess values. Endianess defines how the bytes of a data are ordered within memory. Defines: LE (little-endian) and BE (big-endian). A little-endian representation starts with the least significant byte. A big-endian representation starts with the most significant byte.


Function Summary
string
getAsciiz (in string: stri, inout integer: currPos)
Get a zero terminated string from stri starting from currPos.
string
hex (in string: stri)
Convert a string of bytes to its hexadecimal representation.
string
int16AsTwoBytesLe (in integer: number)
Convert 16 lower bits of an integer into two little-endian chars.
string
int32AsFourBytesLe (in integer: number)
Convert 32 lower bits of an integer into four little-endian chars.
string
int64AsEightBytesLe (in integer: number)
Convert 64 lower bits of an integer into eight little-endian chars.
string
int16AsTwoBytesBe (in integer: number)
Convert 16 lower bits of an integer into two big-endian chars.
string
int32AsFourBytesBe (in integer: number)
Convert 32 lower bits of an integer into four big-endian chars.
string
int64AsEightBytesBe (in integer: number)
Convert 64 lower bits of an integer into eight big-endian chars.
string
bigAsEightBytesLe (in bigInteger: number)
Convert 64 lower bits of a bigInteger into eight little-endian chars.
string
bigAsEightBytesBe (in bigInteger: number)
Convert 64 lower bits of a bigInteger into eight big-endian chars.
string
bytes (in integer: number, in signedness: signed, in endianess: endian)
Convert an integer into a string of bytes.
string
bytes (in bigInteger: number, in signedness: signed, in endianess: endian)
Convert a bigInteger into a string of bytes.
integer
bytes2Int (in string: byteStri, in signedness: signed, in endianess: endian)
Convert a string of bytes to an integer.
bigInteger
bytes2BigInt (in string: byteStri, in signedness: signed, in endianess: endian)
Convert a string of bytes to a bigInteger.
integer
getUInt16Le (inout file: in_file)
Read two bytes from a file and return their little-endian value.
integer
getUInt32Le (inout file: in_file)
Read four bytes from a file and return their little-endian value.
integer
getUInt16Be (inout file: in_file)
Read two bytes from a file and return their big-endian value.
integer
getUInt32Be (inout file: in_file)
Read four bytes from a file and return their big-endian value.

Function Detail

getAsciiz

const func string: getAsciiz (in string: stri, inout integer: currPos)

Get a zero terminated string from stri starting from currPos. CurrPos is advanced after the zero ('\0;') character.

Returns:
the zero terminated string without the zero ('\0;') character.

hex

const func string: hex (in string: stri)

Convert a string of bytes to its hexadecimal representation. Each byte is represented by two hexadecimal digits.

hex("!;Mn")  returns "213b4d6e"
Returns:
the hexadecimal representation of the given string.
Raises:
RANGE_ERROR - When characters beyond '\255;' are present.

int16AsTwoBytesLe

const func string: int16AsTwoBytesLe (in integer: number)

Convert 16 lower bits of an integer into two little-endian chars.

Returns:
a string of length two with the little-endian representation.

int32AsFourBytesLe

const func string: int32AsFourBytesLe (in integer: number)

Convert 32 lower bits of an integer into four little-endian chars.

Returns:
a string of length four with the little-endian representation.

int64AsEightBytesLe

const func string: int64AsEightBytesLe (in integer: number)

Convert 64 lower bits of an integer into eight little-endian chars.

Returns:
a string of length eight with the little-endian representation.

int16AsTwoBytesBe

const func string: int16AsTwoBytesBe (in integer: number)

Convert 16 lower bits of an integer into two big-endian chars.

Returns:
a string of length two with the big-endian representation.

int32AsFourBytesBe

const func string: int32AsFourBytesBe (in integer: number)

Convert 32 lower bits of an integer into four big-endian chars.

Returns:
a string of length four with the big-endian representation.

int64AsEightBytesBe

const func string: int64AsEightBytesBe (in integer: number)

Convert 64 lower bits of an integer into eight big-endian chars.

Returns:
a string of length eight with the big-endian representation.

bigAsEightBytesLe

const func string: bigAsEightBytesLe (in bigInteger: number)

Convert 64 lower bits of a bigInteger into eight little-endian chars.

Returns:
a string of length eight with the little-endian representation.

bigAsEightBytesBe

const func string: bigAsEightBytesBe (in bigInteger: number)

Convert 64 lower bits of a bigInteger into eight big-endian chars.

Returns:
a string of length eight with the big-endian representation.

bytes

const func string: bytes (in integer: number, in signedness: signed, in endianess: endian)

Convert an integer into a string of bytes. The result uses binary representation with a base of 256. The result contains chars (bytes) with an ordinal <= 255.

bytes(1413829460, SIGNED, BE)  returns "TEST"
bytes(1497451343, SIGNED, LE)  returns "OKAY"
Parameters:
number - Integer number to be converted.
signed - Determines the signedness of the result. Possible values are UNSIGNED and SIGNED. When signed is SIGNED the result is encoded with the twos-complement representation. In this case a negative number is converted to a result where the most significant byte has an ordinal >= 128.
endian - Determines the endianess of the result. Possible values are LE for little-endian and BE for big-endian.
Returns:
a string with the shortest binary representation of number.
Raises:
RANGE_ERROR - When number is negative and signed is UNSIGNED.
MEMORY_ERROR - Not enough memory to represent the result.

bytes

const func string: bytes (in bigInteger: number, in signedness: signed, in endianess: endian)

Convert a bigInteger into a string of bytes. The result uses binary representation with a base of 256. The result contains chars (bytes) with an ordinal <= 255.

bytes(1413829460_, SIGNED, BE)                        returns "TEST"
bytes(1497451343_, SIGNED, LE)                        returns "OKAY"
bytes(8316866959935304777_, UNSIGNED, LE)             returns "It works"
bytes(54818063270363344731475178867_, UNSIGNED, BE)   returns "± plus-minus"
bytes(54818063270363344731475178867_, SIGNED, BE)     returns "\0;± plus-minus"
bytes(-24410099243900992862068771469_, SIGNED, BE)    returns "± plus-minus"
bytes(-24410099243900992862068771469_, UNSIGNED, LE)  raises RANGE_ERROR
Parameters:
number - BigInteger number to be converted.
signed - Determines the signedness of the result. Possible values are UNSIGNED and SIGNED. When signed is SIGNED the result is encoded with the twos-complement representation. In this case a negative number is converted to a result where the most significant byte has an ordinal >= 128.
endian - Determines the endianess of the result. Possible values are LE for little-endian and BE for big-endian.
Returns:
a string with the shortest binary representation of number.
Raises:
RANGE_ERROR - When number is negative and signed is UNSIGNED.
MEMORY_ERROR - Not enough memory to represent the result.

bytes2Int

const func integer: bytes2Int (in string: byteStri, in signedness: signed, in endianess: endian)

Convert a string of bytes to an integer.

bytes2Int("I\150;\2;\210;", UNSIGNED, BE)  returns  1234567890
bytes2Int("\210;\2;\150;I", UNSIGNED, LE)  returns  1234567890
bytes2Int(":\222;h\177;", UNSIGNED, BE)    returns   987654321
Parameters:
byteStri - String of bytes to be converted. The bytes are interpreted as binary representation with a base of 256.
signed - Determines the signedness of byteStri. Possible values are UNSIGNED and SIGNED. When signed is SIGNED bstri is interpreted as signed value in the twos-complement representation. In this case the result is negative when the most significant byte has an ordinal >= 128.
endian - Determines the endianess of byteStri. Possible values are LE for little-endian and BE for big-endian.
Returns:
an integer created from byteStri.
Raises:
RANGE_ERROR - When characters beyond '\255;' are present or when the result value cannot be represented with an integer.

bytes2BigInt

const func bigInteger: bytes2BigInt (in string: byteStri, in signedness: signed, in endianess: endian)

Convert a string of bytes to a bigInteger.

bytes2BigInt("I\150;\2;\210;", SIGNED, BE)        returns  1234567890_
bytes2BigInt("\210;\2;\150;I", UNSIGNED, LE)      returns  1234567890_
bytes2BigInt(":\222;h\177;", SIGNED, BE)          returns   987654321_
bytes2BigInt("\139;\208;\3;\152;", UNSIGNED, BE)  returns  2345665432_
bytes2BigInt("\139;\208;\3;\152;", SIGNED, BE)    returns -1949301864_
bytes2BigInt("\152;\3;\208;\139;", UNSIGNED, LE)  returns  2345665432_
Parameters:
byteStri - String of bytes to be converted. The bytes are interpreted as binary representation with a base of 256.
signed - Determines the signedness of byteStri. Possible values are UNSIGNED and SIGNED. When signed is SIGNED bstri is interpreted as signed value in the twos-complement representation. In this case the result is negative when the most significant byte has an ordinal >= 128.
endian - Determines the endianess of byteStri. Possible values are LE for little-endian and BE for big-endian.
Returns:
a bigInteger created from byteStri.
Raises:
RANGE_ERROR - When characters beyond '\255;' are present.
MEMORY_ERROR - Not enough memory to represent the result.

getUInt16Le

const func integer: getUInt16Le (inout file: in_file)

Read two bytes from a file and return their little-endian value.


getUInt32Le

const func integer: getUInt32Le (inout file: in_file)

Read four bytes from a file and return their little-endian value.


getUInt16Be

const func integer: getUInt16Be (inout file: in_file)

Read two bytes from a file and return their big-endian value.


getUInt32Be

const func integer: getUInt32Be (inout file: in_file)

Read four bytes from a file and return their big-endian value.



 previous   up   next