WoW LibCompress addon Shadowlands/Burning Crusade Classic 2021
logo
wow addon LibCompress

LibCompress

Game Version: 9.0.2
Total Downloads: 43,208
Updated: Feb 28, 2021
Created: Jun 1, 2008
download LibCompressDownload Earlier Versions

Earlier Versions

Name Size Uploaded Game Version Downloads
r86-release release 17.00 KB Feb 28, 2021 9.0.2 0 download LibCompress r86-release releaseDownload
r84-release release 17.05 KB Jul 3, 2018 7.3.5 3,748 download LibCompress r84-release releaseDownload
r82-release release 17.08 KB Feb 25, 2018 7.3.5 1,472 download LibCompress r82-release releaseDownload
r78-release release 17.02 KB Jul 15, 2017 7.2.5 2,369 download LibCompress r78-release releaseDownload
r76-release release 17.40 KB Nov 6, 2016 7.1.0 3,802 download LibCompress r76-release releaseDownload
r73-release release 17.31 KB Aug 28, 2016 7.0.3 3,390 download LibCompress r73-release releaseDownload
7.0-release1 release 16.52 KB Jul 19, 2016 7.0.3 2,529 download LibCompress 7.0-release1 releaseDownload
r69-release release 16.66 KB Apr 13, 2016 6.2.4 2,183 download LibCompress r69-release releaseDownload
r65-release release 16.60 KB Aug 23, 2015 6.2.0 3,401 download LibCompress r65-release releaseDownload
r60-release release 17.18 KB Jan 16, 2015 6.0.3 3,437 download LibCompress r60-release releaseDownload
r49-release +1 More release 13.97 KB Jan 4, 2011 4.0.3a 7,566 download LibCompress r49-release

+1 More releaseDownload
r42-release +1 More release 13.91 KB Jul 4, 2010 3.3.5 785 download LibCompress r42-release

+1 More releaseDownload
LibCompress r42-release +1 More release 14.03 KB Dec 12, 2009 3.3.0 548 download LibCompress LibCompress r42-release

+1 More releaseDownload
LibCompress r40-release +1 More release 13.94 KB Aug 5, 2009 3.2.0 864 download LibCompress LibCompress r40-release

+1 More releaseDownload
r38-release +1 More release 13.91 KB May 3, 2009 3.1.0 182 download LibCompress r38-release

+1 More releaseDownload
r36-release release 14.71 KB Nov 24, 2008 3.0.3 96 download LibCompress r36-release releaseDownload
r32-release release 8.52 KB Nov 18, 2008 3.0.3 97 download LibCompress r32-release releaseDownload
r30-release release 8.40 KB Nov 16, 2008 3.0.3 94 download LibCompress r30-release releaseDownload
r27-release release 7.96 KB Oct 29, 2008 3.0.2 110 download LibCompress r27-release releaseDownload
LibCompress-r75740 beta 8.57 KB Jun 1, 2008 2.4.3 254 download LibCompress LibCompress-r75740 betaDownload
LibCompress-r74189 beta 7.30 KB May 17, 2008 2.4.3 98 download LibCompress LibCompress-r74189 betaDownload
LibCompress-r73518 beta 3.46 KB May 11, 2008 2.4.3 126 download LibCompress LibCompress-r73518 betaDownload
r83-alpha alpha 16.69 KB Jul 3, 2018 7.3.5 88 download LibCompress r83-alpha alphaDownload
r81-alpha alpha 17.07 KB Feb 25, 2018 7.3.5 50 download LibCompress r81-alpha alphaDownload
r80-alpha alpha 16.99 KB Feb 23, 2018 7.2.5 58 download LibCompress r80-alpha alphaDownload
r79-alpha alpha 16.71 KB Feb 23, 2018 7.2.5 40 download LibCompress r79-alpha alphaDownload
r77-alpha alpha 16.74 KB Jul 13, 2017 7.2.5 103 download LibCompress r77-alpha alphaDownload
r75 alpha 17.34 KB Nov 6, 2016 7.1.0 125 download LibCompress r75 alphaDownload
r74 alpha 17.24 KB Nov 6, 2016 7.1.0 90 download LibCompress r74 alphaDownload
r72 alpha 17.23 KB Aug 28, 2016 7.0.3 62 download LibCompress r72 alphaDownload
r70 alpha 16.46 KB Jul 19, 2016 7.0.3 61 download LibCompress r70 alphaDownload
r68 alpha 16.60 KB Apr 13, 2016 6.2.4 63 download LibCompress r68 alphaDownload
r67 alpha 16.61 KB Aug 24, 2015 6.2.0 316 download LibCompress r67 alphaDownload
r65 alpha 16.55 KB Aug 23, 2015 6.2.0 59 download LibCompress r65 alphaDownload
r64 alpha 16.50 KB Aug 23, 2015 6.2.0 79 download LibCompress r64 alphaDownload
r60 alpha 17.13 KB Jan 16, 2015 6.0.3 62 download LibCompress r60 alphaDownload
r58 alpha 17.10 KB Jan 16, 2015 6.0.3 62 download LibCompress r58 alphaDownload
r56 alpha 17.06 KB Jan 16, 2015 6.0.3 75 download LibCompress r56 alphaDownload
r55 alpha 16.96 KB Jan 16, 2015 6.0.3 67 download LibCompress r55 alphaDownload
r54 alpha 16.91 KB Jan 16, 2015 6.0.3 55 download LibCompress r54 alphaDownload
r53 alpha 16.85 KB Jan 16, 2015 6.0.3 62 download LibCompress r53 alphaDownload
r52 alpha 16.79 KB Jan 16, 2015 6.0.3 68 download LibCompress r52 alphaDownload
r51 +1 More alpha 20.93 KB Jan 16, 2015 6.0.3 66 download LibCompress r51

+1 More alphaDownload
r49 +1 More alpha 13.91 KB Jan 4, 2011 4.0.3a 79 download LibCompress r49

+1 More alphaDownload
r42 +1 More alpha 13.94 KB Dec 12, 2009 3.3.0 80 download LibCompress r42

+1 More alphaDownload
r40 +1 More alpha 13.85 KB Aug 5, 2009 3.2.0 61 download LibCompress r40

+1 More alphaDownload
r38 +1 More alpha 13.85 KB May 3, 2009 3.1.0 56 download LibCompress r38

+1 More alphaDownload
r36 alpha 14.20 KB Nov 24, 2008 3.0.3 42 download LibCompress r36 alphaDownload
r35 alpha 14.09 KB Nov 24, 2008 3.0.3 50 download LibCompress r35 alphaDownload
r34 alpha 10.68 KB Nov 23, 2008 3.0.3 64 download LibCompress r34 alphaDownload
r32 alpha 7.99 KB Nov 18, 2008 3.0.3 48 download LibCompress r32 alphaDownload
r30 alpha 7.85 KB Nov 16, 2008 3.0.3 50 download LibCompress r30 alphaDownload
r29 alpha 7.46 KB Nov 16, 2008 3.0.3 52 download LibCompress r29 alphaDownload
r27 alpha 7.51 KB Oct 29, 2008 2.4.3 89 download LibCompress r27 alphaDownload
r27 alpha 7.51 KB Oct 9, 2008 2.4.3 59 download LibCompress r27 alphaDownload

Description

Share this:

LibCompress is a compression and decompression library implemented entirely in WoW-friendly Lua. It supports the LZW and Huffman algorithms, and can automatically choose the most efficient algorithm for your data. One popular usage for this library is to send a compressed table to another player or add-on. Doing this requires additional encoding to remove the \000 characters from the data stream.

Take a look at the forum post for more info and a development discussion:

[http://forums.wowace.com/showthread.php?t=12660]

Usage:

Compression

Load the library with:

libc = LibStub:GetLibrary("LibCompress")

Compress data (must be in string form):

compressed_data = libc:Compress(data)

This will try all compression algorithms and return the best compressed result. It is possible to specify a specific compression algorithm like this:

compressed_data = libc:CompressHuffman(data)

or

 compressed_data = libc:CompressLZW(data)

Data will either be compressed with the Huffman compression algorithm or not at all. Data returned with a prefix byte identifying that the data is decompressed.

To decompress the data, simply use this:

 decompressed_data = libc:Decompress(compressed_data)

Compress and Decompress can return an error and this is signaled by the first returned argument being nil and the second the error message. So checking for that would be appropriate.

Encoding

LibCompress also has the possibility to encode and decode data, preparing it for transmission over the addon channel or chat channel (or a custom encoding). Two forms of encoding is provided:

Prefix encoding

The first form is prefix-encoding. Basically, reserved characters are replaced with a prefix/escape character followed by the suffix character, i.e. reserved bytes are replaced by a double-byte combination. This is how it is done:

 table, msg = libc:GetEncodeTable(reservedChars, escapeChars,  mapChars)

reservedChars: The characters in this string will not appear in the encoded data.
escapeChars: A string of characters used as escape-characters (don’t supply more than needed). #escapeChars >= 1
mapChars: First characters in reservedChars maps to first characters in mapChars. (#mapChars <= #reservedChars)

If table is nil, then msg holds an error message. Otherwise the usage is simple:

encoded_message = table:Encode(message)

 message = table:Decode(encoded_message)

Two predefined setups have been included:

GetAddonEncodeTable: Sets up encoding for the addon channel (\000 is encoded)

GetChatEncodeTable: Sets up encoding for the chat channel (many bytes encoded, see the function for details)

7-bit encoding

This encoding packs bits, not bytes. It puts 7 bits into every byte, enlarging the data by approx 14%. Values from 0 to 127 (both inclusive) are present in the encoded data and therefor has to be prefix-encoded as well. This encoding generates a bit of string trash and should be used with consideration.

Encode data like this:

 encoded_data = libc:Encode7bit(data)

Decode data like this:

 decoded_data = libc:Decode7bit(encoded_data)

Checksum/hash algorithms

LibCompress also provides 2 reasonable fast hash algorithms. They are converted from a C-implementation to lua and are quite fast. The hash value is either 16 bit or 32 bit.

Use like this (data1, data2, data… = string):

 code = libc:fcs16init()
 code = libc:fcs16update(code, data1)
 code = libc:fcs16update(code, data2)
 code = libc:fcs16update(code, data...)
 code = libc:fcs16final(code)

data = string
fcs16 provides a 16 bit checksum, fcs32 provides a 32 bit checksum.

Comments

Add a comment