utils.compress

Compress a string

Prototype

s = utils.compress (s [, method] )

Description

Compresses string s and returns the compressed form. Note that it may contain nulls (bytes with a zero value).

The optional argument 'method' indicates the level of compression you want. The default, if omitted, is 6.

eg.

comp = utils.compress ("this is a fine thing")
For short strings the compressed data may be longer than the uncompressed data because of a 12-byte "compression information" header that is prepended to the compressed data. For longer text (such as the section above about the Lua sandbox), the compression ratio is about 50%.

Lua functions

Topics