PilotScript Text/Binary Conversion Functions

The following text/binary conversion functions are available for PilotScript components.

Text/Binary Conversion Function Name/Prototype Description Example

Compress

ByteArray Compress(ByteArray bytes)
Compresses a binary byte array into a more compact byte array.
imagecomp := compress(image);

Compresses the binary image property and assigns it to the property imagecomp. The degree of compression depends upon the nature of the original data.

ConvertBytesToString

String ConvertBytesToString(ByteArray bytes[, Number encoding=8])

Interprets the supplied byte stream as a unicode text representation with the given encoding. If no encoding is specified, UTF-8 is assumed. Currently supported values for encoding include:

1: ISO-8859-1

2: UCS-2 (Big Endian)

3: UCS-2 (Little Endian)

8: UTF-8

ctab := convertbytestostring(ctab_blob, 1);

Converts the ISO-8859-1 encoded byte array into a string; useful for retrieving text information from databases stored in a binary representation.

ConvertFromBase64

ByteArray ConvertFromBase64(String string)
Converts a base64 string and returns a binary byte array.
image := convertfrombase64(b64str);

Converts the base64 encoded string value b64str to a binary value and assigns it to the property image.

ConvertFromDaylight

Bitset ConvertFromDaylight(String daylight)
Converts the given Daylight fingerprint string and returns a binary fingerprint (that is, a bitset).
scitegic_fp := convertfromdaylight(dayfp);

Converts the Daylight fingerprint string in property dayfp into a binary representation and assigns it to the property scitegic_fp.

ConvertFromHex

ByteArray ConvertFromHex(String string)
Converts a hex encoded string and returns a binary byte array.
image := convertfromhex(hexstr);

Converts the hex encoded string value hexstr to a binary value and assigns it to the property image.

ConvertStringToBytes

ByteArray ConvertStringToBytes(String string[, Number encoding=8])

Converts the supplied text string and returns the specified binary unicode encoding as an array of bytes. If no encoding is specified, UTF-8 is assumed. Currently supported values for encoding include:

1: ISO-8859-1

2: UCS-2 (Big Endian)

3: UCS-2 (Little Endian)

8: UTF-8

ctab_blob := convertstringtobytes(ctab, 3);

Converts the ctab property into a UCS-2 encoded array of bytes. This is useful for writing strings into database blob fields.

ConvertToBase64

String ConvertToBase64(ByteArray bytes)
Converts the binary value and returns a base64 encoded string.
b64str := converttobase64(image);

Converts the binary image property to a base64 encoded string and assigns it to the property b64str. Base64 encoding is more compact than hex encoding.

ConvertToDaylight

String ConvertToDaylight(ByteArray bytes|Bitset bitset|String binaryString|Fingerprint fp)
Converts the give binary fingerprint and returns a Daylight fingerprint string.
dayfp := converttodaylight(scitegic_fp);

Converts the binary fingerprint value scitegic_fp into a Daylight fingerprint string and assigns it to the property dayfp.

ConvertToHex

String ConvertToHex(ByteArray bytes)
Converts a binary value and returns a string of hex characters (A-F, 0-9).
hexstr := converttohex(image);

Converts the binary image attribute to a hex string and assigns it to the property hexstr.

Uncompress

ByteArray Uncompress(ByteArray bytes)
Uncompresses a previously compressed binary byte array.
image := uncompress(imagecomp);

Uncompresses the binary imagecomp property, restoring the data to its state before compression, and assigns it to the property image.