miniz - Easy zlib compression#
Adapted Air780E Air780EP Air780EPS Air780EQ Air700EAQ Air700EMQ Air700ECQ Air201
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Example
-- Prepare the data
local bigdata = "123jfoiq4hlkfjbnasdilfhuqwo;hfashfp9qw38hrfaios;hfiuoaghfluaeisw"
-- compressed, the compressed data is zlib-compatible, other languages can be decompressed through zlib-related libraries
local cdata = miniz.compress(bigdata)
-- lua The string of is equivalent to char[] with length, which can store all data including 0x 00
if cdata then
-- Check data size before and after compression
log.info("miniz", "before", #bigdata, "after", #cdata)
log.info("miniz", "cdata as hex", cdata:toHex())
-- Decompress to get the original text
local udata = miniz.uncompress(cdata)
log.info("miniz", "udata", udata)
end
Constant#
constant |
type |
explanation |
---|---|---|
miniz.WRITE_ZLIB_HEADER |
int |
compression parameter, whether to write zlib header data, compress the default value of the function |
miniz.COMPUTE_ADLER32 |
int |
Compression/Decompression Parameters, Calculation/Verification adler-32 |
miniz.GREEDY_PARSING_FLAG |
int |
The compression parameter, whether to process quickly greedy, and the slower processing mode is used by default. |
miniz.NONDETERMINISTIC_PARSING_FLAG |
int |
compression parameters, whether to quickly initialize the compressor |
miniz.RLE_MATCHES |
int |
compression parameters, scan only RLE |
miniz.FILTER_MATCHES |
int |
Compression parameter, filtering characters less than 5 times |
miniz.FORCE_ALL_STATIC_BLOCKS |
int |
Compression parameter, whether to disable the optimized Huffman table. |
miniz.FORCE_ALL_RAW_BLOCKS |
int |
Compression parameter, whether to only use raw blocks |
miniz.PARSE_ZLIB_HEADER |
int |
Decompression parameter, whether to process the zlib header, uncompress the default value of the function. |
miniz.HAS_MORE_INPUT |
int |
Decompression parameters, whether there is more data, only streaming decompression is available, not currently supported |
miniz.USING_NON_WRAPPING_OUTPUT_BUF |
int |
Decompression parameters, whether the decompression interval is sufficient for all data,, only streaming decompression is available, not currently supported |
miniz.COMPUTE_ADLER32 |
int |
Decompression parameters, mandatory verification adler-32 |
miniz.compress(data, flags)#
Fast compression, requires 165kb of system memory and 32kb of LuaVM memory
Parameters
Incoming Value Type |
Explanation |
---|---|
string |
The data to be compressed. It is not recommended to compress data less than 400 bytes, and the compressed data cannot be larger 32k. |
flags |
The compression parameter, which is miniz.WRITE_ZLIB_HEADER by default, that is, written to the zlib header |
Return Value
return value type |
explanation |
---|---|
string |
If the compression is successful, return the data string, otherwise return nil |
Examples
local bigdata = "123jfoiq4hlkfjbnasdilfhuqwo;hfashfp9qw38hrfaios;hfiuoaghfluaeisw"
local cdata = miniz.compress(bigdata)
if cdata then
log.info("miniz", "before", #bigdata, "after", #cdata)
log.info("miniz", "cdata as hex", cdata:toHex())
end
miniz.uncompress(data, flags)#
Fast decompression, requires 32kb of LuaVM memory
Parameters
Incoming Value Type |
Explanation |
---|---|
string |
Data to be decompressed. The decompressed data cannot be greater 32k |
flags |
Decompression parameter. The default value is miniz.PARSE_ZLIB_HEADER, that is, the zlib header is parsed. |
Return Value
return value type |
explanation |
---|---|
string |
If the decompression is successful, return the data string, otherwise return nil |
Examples
local bigdata = "123jfoiq4hlkfjbnasdilfhuqwo;hfashfp9qw38hrfaios;hfiuoaghfluaeisw"
local cdata = miniz.compress(bigdata)
if cdata then
log.info("miniz", "before", #bigdata, "after", #cdata)
log.info("miniz", "cdata as hex", cdata:toHex())
local udata = miniz.uncompress(cdata)
log.info("miniz", "udata", udata)
end