Garry's Mod Wiki

util.Decompress

  string util.Decompress( string compressedString, number maxSize = nil )

Description

Decompresses the given string using LZMA algorithm. Used to decompress strings previously compressed with util.Compress.

This function expects the compressed input data to have the uncompressed size of the data prepended to it as an 8-byte little-endian integer. Source

If your compressed input data was compressed by util.Compress, you don't need to worry about this - the uncompressed size of the data is already prepended to its output.

However, if your compressed data was produced using standard tools outside of Garry's Mod, you will need to manually prepend the length of the uncompressed data to its compressed form as an 8-byte little endian integer, or use third-party tools such as gmod-lzma to compress your data instead.

Arguments

1 string compressedString
The compressed string to decompress.
2 number maxSize = nil
The maximum size of uncompressed data in bytes, if greater it fails.

Returns

1 string
The original, decompressed string or nil on failure or invalid input. Also returns empty string if the input string was zero length ("").