Core Function BinaryCompress
From Sputnik Wiki
(Difference between revisions)
(→Example) |
m (1 revision) |
(One intermediate revision by one user not shown) |
Latest revision as of 12:38, 14 June 2015
BinaryCompress( <binary-array> )
Contents |
Description
Compress a binary variables data.
Parameters
binary-array
The binary variable to compress.
Return Value
Success: Returns 1.
Failure: Returns 0.
Remarks
This uses a standard gzip memory stream compression.
This function can greatly reduce the size of binary data however its best used on large amounts of data since its effectiveness is limited on small data.
Example
$binary = Pack("A*", ("Hello World!\n" x 1000)); println("Size uncompressed : " . BinaryLen($binary)); BinaryCompress($binary); println("Size compressed : " . BinaryLen($binary)); BinaryUncompress($binary); println("Size uncompressed (again) : " . BinaryLen($binary)); inputC("\nPress any key to see whats inside the binary variable after compress and decompress"); println( Unpack("A*", $binary, 3) ); # Prints "Hello World!" 1000 times