warframe

This is the documentation page for Module:Codec


Codec is a library for (de)compression algorithms implemented in pure Lua. Originally created for World of Warcraft as LibCompress.lua, the library has been ported to be used on MediaWiki-based wikis.

Authors: jjsheets and Galmok of European Stormrage (Horde) Email : sheets.jeff@gmail.com and galmok@gmail.com Licence: GPL version 2 (General Public License) Revision: $Revision: 83 $ Date: $Date: 2018-07-03 14:33:48 +0000 (Tue, 03 Jul 2018) $

Source

For more documentation and original source see https://www.wowace.com/projects/libcompress

Documentation

Package items

LibCompress:CompressLZW(uncompressed) (function)
Compresses a string using LZW algorithm. Unless the uncompressed string starts with "\002", this is guaranteed to return a string equal to or smaller than the passed string. the returned string will only contain "\000" characters in rare circumstances, and will contain none if the source string has none.
Parameter: uncompressed Raw string to be compressed using LZW algorithm (string)
Returns: compressed string if the resultant string is smaller than the original input, otherwise returns the original input since compression does not result in smaller size (string)
LibCompress:DecompressLZW(compressed) (function)
Decompresses a string using LZW algorithm. If the passed string is a compressed string, this will decompress it and return the decompressed string. Otherwise it return an error message Compressed strings are marked by beginning with "\002"
Parameter: compressed LZW compressed string to be decompressed (string)
Returns: uncompressed result (string)
LibCompress:CompressHuffman(uncompressed) (function)
Compresses a string using Huffman coding algorithm. Word size for this huffman algorithm is 8 bits (1 byte). This means the best compression is representing 1 byte with 1 bit, i.e. compress to 0.125 of original size.
Parameter: uncompressed Raw string to be compressed using Huffman coding algorithm (string)
Returns: compressed string if the resultant string is smaller than the original input, otherwise returns the original input since compression does not result in smaller size (string)
LibCompress:DecompressHuffman(compressed) (function)
Decompresses a string using Huffman coding algorithm.
Parameter: compressed Huffman compressed string to be decompressed (string)
Returns: uncompressed result (string)
LibCompress:Store(uncompressed) (function)
Prepends "\001" to uncompressed string to mark as uncompressed.
Parameter: uncompressed Raw uncompressed string (string)
Returns: Uncompressed string prepended with "\001" (string)
LibCompress:DecompressUncompressed(data) (function)
Returns uncompressed string without prepended codec (e. g. "\001" or "\003").
Parameter: data Raw uncompressed string (string)
Returns: Uncompressed string without prepended codec (string)
LibCompress:Compress(data) (function)
Generic method that tries all compression codecs (LZW and Huffman) and return the best result.
Parameter: data Raw uncompressed string (string)
Returns: compressed string if the resultant string is smaller than the original input, otherwise returns the original input since compression does not result in smaller size (string)
LibCompress:Decompress(data) (function)
Generic method to decompress either a LZW or Huffman compressed string.
Parameter: data LZW or Huffman compressed string to be decompressed (string)
Returns: uncompressed result (string)
LibCompress:GetEncodeTable(reservedChar, escapeChars, mapChars) (function)
Builds an encoding table.
Parameters:
  • reservedChar String of reserved characters with no spaces between each unique character (string)
  • escapeChars String of escape characters with no spaces between each unique character (string)
  • mapChars Sting of characters with no spaces between each unique character; used for encoding reserved characters (string)
Returns: Encoding table (table)
LibCompress:GetAddonEncodeTable(reservedChar, escapeChars, mapChars) (function)
Addons: Call this only once and reuse the returned table for all encodings/decodings.
Parameters:
  • reservedChar String of reserved characters with no spaces between each unique character (string)
  • escapeChars String of escape characters with no spaces between each unique character (string)
  • mapChars Sting of characters with no spaces between each unique character; used for encoding reserved characters (string)
Returns: Encoding table (table)
LibCompress:GetChatEncodeTable(reservedChar, escapeChars, mapChars) (function)
Addons: Call this only once and reuse the returned table for all encodings/decodings.
Parameters:
  • reservedChar String of reserved characters with no spaces between each unique character (string)
  • escapeChars String of escape characters with no spaces between each unique character (string)
  • mapChars Sting of characters with no spaces between each unique character; used for encoding other characters (string)
Returns: Encoding table (table)
LibCompress:Encode7bit(str) (function)
Encodes data using values from 0 to 127 inclusive.
Parameter: str String to be encoded (string)
Returns: Encoded data using 7 bits (string)
LibCompress:Decode7bit(str) (function)
Decodes data that has only values from 0 to 127 inclusive.
Parameter: str String to be decoded (string)
Returns: Decoded data (string)
LibCompress:fcs16init() (function)
Initializes FCS-16 checksum/hash.
Returns: Value for an unsigned 16 bit integer that has all bits set (number)
LibCompress:fcs16update(uFcs16, pBuffer) (function)
Updates FCS-16 checksum/hash.
Parameters:
  • uFcs16 FCS-16 checksum/hash (number)
  • pBuffer Data input (string)
Returns: Resultant checksum/hash (number)
LibCompress:fcs16final(uFcs16) (function)
Performs the final bitwise XOR operation for FCS-16 checksum/hash.
Parameter: uFcs16 FCS-16 checksum/hash (number)
Returns: Resultant checksum/hash (number)
LibCompress:FCS16(...) (function)
Creates a FCS-16 checksum/hash based on input data.
Parameter: ... Input data (string)
Returns: Resultant checksum/hash (number)
LibCompress:fcs16init() (function)
Initializes FCS-32 checksum/hash.
Returns: Value for a signed 32 bit integer that has all bits set (number)
LibCompress:fcs32update(uFcs32, pBuffer) (function)
Updates FCS-32 checksum/hash.
Parameters:
  • uFcs32 FCS-32 checksum/hash (number)
  • pBuffer Data input (string)
Returns: Resultant checksum/hash (number)
LibCompress:fcs32final(uFcs32) (function)
Performs the final bitwise NOT operation for FCS-32 checksum/hash.
Parameter: uFcs32 FCS-32 checksum/hash (number)
Returns: Resultant checksum/hash (number)
LibCompress:FCS32(...) (function)
Creates a FCS-32 checksum/hash based on input data.
Parameter: ... Input data (string)
Returns: Resultant checksum/hash (number)

Created with Docbunto

See Also


Code