Earlier Versions
Name | Size | Uploaded | Game Version | Downloads | |
r86-release release | 17.00 KB | Feb 28, 2021 | 9.0.2 | 0 | ![]() |
r84-release release | 17.05 KB | Jul 3, 2018 | 7.3.5 | 3,748 | ![]() |
r82-release release | 17.08 KB | Feb 25, 2018 | 7.3.5 | 1,472 | ![]() |
r78-release release | 17.02 KB | Jul 15, 2017 | 7.2.5 | 2,369 | ![]() |
r76-release release | 17.40 KB | Nov 6, 2016 | 7.1.0 | 3,802 | ![]() |
r73-release release | 17.31 KB | Aug 28, 2016 | 7.0.3 | 3,390 | ![]() |
7.0-release1 release | 16.52 KB | Jul 19, 2016 | 7.0.3 | 2,529 | ![]() |
r69-release release | 16.66 KB | Apr 13, 2016 | 6.2.4 | 2,183 | ![]() |
r65-release release | 16.60 KB | Aug 23, 2015 | 6.2.0 | 3,401 | ![]() |
r60-release release | 17.18 KB | Jan 16, 2015 | 6.0.3 | 3,437 | ![]() |
r49-release +1 More release | 13.97 KB | Jan 4, 2011 | 4.0.3a | 7,566 | ![]() |
r42-release +1 More release | 13.91 KB | Jul 4, 2010 | 3.3.5 | 785 | ![]() |
LibCompress r42-release +1 More release | 14.03 KB | Dec 12, 2009 | 3.3.0 | 548 | ![]() |
LibCompress r40-release +1 More release | 13.94 KB | Aug 5, 2009 | 3.2.0 | 864 | ![]() |
r38-release +1 More release | 13.91 KB | May 3, 2009 | 3.1.0 | 182 | ![]() |
r36-release release | 14.71 KB | Nov 24, 2008 | 3.0.3 | 96 | ![]() |
r32-release release | 8.52 KB | Nov 18, 2008 | 3.0.3 | 97 | ![]() |
r30-release release | 8.40 KB | Nov 16, 2008 | 3.0.3 | 94 | ![]() |
r27-release release | 7.96 KB | Oct 29, 2008 | 3.0.2 | 110 | ![]() |
LibCompress-r75740 beta | 8.57 KB | Jun 1, 2008 | 2.4.3 | 254 | ![]() |
LibCompress-r74189 beta | 7.30 KB | May 17, 2008 | 2.4.3 | 98 | ![]() |
LibCompress-r73518 beta | 3.46 KB | May 11, 2008 | 2.4.3 | 126 | ![]() |
r83-alpha alpha | 16.69 KB | Jul 3, 2018 | 7.3.5 | 88 | ![]() |
r81-alpha alpha | 17.07 KB | Feb 25, 2018 | 7.3.5 | 50 | ![]() |
r80-alpha alpha | 16.99 KB | Feb 23, 2018 | 7.2.5 | 58 | ![]() |
r79-alpha alpha | 16.71 KB | Feb 23, 2018 | 7.2.5 | 40 | ![]() |
r77-alpha alpha | 16.74 KB | Jul 13, 2017 | 7.2.5 | 103 | ![]() |
r75 alpha | 17.34 KB | Nov 6, 2016 | 7.1.0 | 125 | ![]() |
r74 alpha | 17.24 KB | Nov 6, 2016 | 7.1.0 | 90 | ![]() |
r72 alpha | 17.23 KB | Aug 28, 2016 | 7.0.3 | 62 | ![]() |
r70 alpha | 16.46 KB | Jul 19, 2016 | 7.0.3 | 61 | ![]() |
r68 alpha | 16.60 KB | Apr 13, 2016 | 6.2.4 | 63 | ![]() |
r67 alpha | 16.61 KB | Aug 24, 2015 | 6.2.0 | 316 | ![]() |
r65 alpha | 16.55 KB | Aug 23, 2015 | 6.2.0 | 59 | ![]() |
r64 alpha | 16.50 KB | Aug 23, 2015 | 6.2.0 | 79 | ![]() |
r60 alpha | 17.13 KB | Jan 16, 2015 | 6.0.3 | 62 | ![]() |
r58 alpha | 17.10 KB | Jan 16, 2015 | 6.0.3 | 62 | ![]() |
r56 alpha | 17.06 KB | Jan 16, 2015 | 6.0.3 | 75 | ![]() |
r55 alpha | 16.96 KB | Jan 16, 2015 | 6.0.3 | 67 | ![]() |
r54 alpha | 16.91 KB | Jan 16, 2015 | 6.0.3 | 55 | ![]() |
r53 alpha | 16.85 KB | Jan 16, 2015 | 6.0.3 | 62 | ![]() |
r52 alpha | 16.79 KB | Jan 16, 2015 | 6.0.3 | 68 | ![]() |
r51 +1 More alpha | 20.93 KB | Jan 16, 2015 | 6.0.3 | 66 | ![]() |
r49 +1 More alpha | 13.91 KB | Jan 4, 2011 | 4.0.3a | 79 | ![]() |
r42 +1 More alpha | 13.94 KB | Dec 12, 2009 | 3.3.0 | 80 | ![]() |
r40 +1 More alpha | 13.85 KB | Aug 5, 2009 | 3.2.0 | 61 | ![]() |
r38 +1 More alpha | 13.85 KB | May 3, 2009 | 3.1.0 | 56 | ![]() |
r36 alpha | 14.20 KB | Nov 24, 2008 | 3.0.3 | 42 | ![]() |
r35 alpha | 14.09 KB | Nov 24, 2008 | 3.0.3 | 50 | ![]() |
r34 alpha | 10.68 KB | Nov 23, 2008 | 3.0.3 | 64 | ![]() |
r32 alpha | 7.99 KB | Nov 18, 2008 | 3.0.3 | 48 | ![]() |
r30 alpha | 7.85 KB | Nov 16, 2008 | 3.0.3 | 50 | ![]() |
r29 alpha | 7.46 KB | Nov 16, 2008 | 3.0.3 | 52 | ![]() |
r27 alpha | 7.51 KB | Oct 29, 2008 | 2.4.3 | 89 | ![]() |
r27 alpha | 7.51 KB | Oct 9, 2008 | 2.4.3 | 59 | ![]() |
Description
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.
Add a comment