Download
(4Kb)
Download
Updated: 10-01-06 10:04 PM
Updated:10-01-06 10:04 PM
Created:unknown
Downloads:2,347
Favorites:2
MD5:

lzwLib-1.0

Version: 1.0
by: Brodrick [More]

A simple lua LZW compression library.

----

Syntax:

lzw:compress("string"[,chatsafe][,CompressTable,TableSize]);
returns compressed string

lzw:decompress("string"[,chatsafe][,CompressTable,TableSize]);
returns decompressed string

----

Typical usage:

----

local compressed = lzw:compress("Some text or arbitrary data in a string");
local decompressed = lzw:decompress(compressed);

----

Optimal compression can be achieved by creating code tables for specific input sets. For example:

----

local DecompressTable = {};
local CompressTable = {};
local TableSize;

lzw:begin_analyze();

for all input strings...
lzw:analyze_string( Str );
...

TableSize = lzw:end_analyze(DecompressTable, CompressTable);

local compressed = lzw:compress("Some data to compress", nil, CompressTable, TableSize);
local decompressed = lzw:decompress(compressed, nil, DecompressTable, TableSize);

----

Note that the decompression table and table size must be stored to be able to decompress data at a later point in time.

----

The resulting compressed string can optionally be output in a chat safe format.

----

local compressed = lzw:compress( Str, true );
local decompressed = lzw:decompress( Str, true );

----

Note that a string that has been compressed using the chat safe flag must be decompressed with the flag or the decompressed
string may become garbled.

Optional Files (0)


Post A Reply Comment Options
Unread 02-08-07, 01:12 PM  
Tokter
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 1
Uploads: 1
Found a bug and a few changes that are necessary:

Line 118:
for k, v in var do -> for k, v in pairs(var) do

Line 285:
Input = string.gsub(Input, specialpercent, percent); -> Input = string.gsub(Input, specialpercent, percentpercent);

Line 413:
for k, v in self.AnalyzeCharacters do -> for k, v in pairs(self.AnalyzeCharacters) do

Line 418:
for k, v in OutReverseTable do -> for k, v in pairs(OutReverseTable) do
Report comment to moderator  
Reply With Quote
Unread 10-02-06, 11:31 AM  
Brodrick
A Fallenroot Satyr
AddOn Author - Click to view AddOns

Forum posts: 25
File comments: 14
Uploads: 7
Originally posted by kaylen
The US LZW patents expired a couple years ago, it should be fine now. I can't speak for other countries, though.
The fact the patents had expired was a major reason why lzw was used.
__________________
- Brodrick (aka Kirov)
Report comment to moderator  
Reply With Quote
Unread 10-02-06, 09:09 AM  
kaylen
A Murloc Raider
AddOn Author - Click to view AddOns

Forum posts: 6
File comments: 40
Uploads: 1
The US LZW patents expired a couple years ago, it should be fine now. I can't speak for other countries, though.
Report comment to moderator  
Reply With Quote
Unread 10-02-06, 07:09 AM  
Miravlix
A Defias Bandit
 
Miravlix's Avatar
AddOn Author - Click to view AddOns

Forum posts: 2
File comments: 1
Uploads: 2
Unhappy Lzw Patent

http://en.wikipedia.org/wiki/LZW#Patent_issues

Great work making lzw for Bliz Lua, but unfortuanately it's a cesspool of patent crap.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: