Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

string compression routine?

Hi everybody!

I'm looking for a set of routines (not necessarily a component - actually: preferably not a component) than can compress strings to a reasonable size (i.e. smaller than 50% for plain text)

Quite a while ago, I used to have a library called "HyperString", but
a) it only compressed BY 35% in stream-compression
b) the block compression compressed by rougly 45%, but was cumbersome to use (block length limited to 64K)

Any ideas? I am NOT looking for a component that will create ZIP-files for me!! For specific reasons, I want to compress only certain parts of a file, the rest must be accessible without decompression (header-information)

Would be nice if it was freeware or at least cheap since I won't earn money with my program...

Thanks for your help!
0
Thesan
Asked:
Thesan
1 Solution
 
MadshiCommented:
Look at paszlib. Perhaps it's what you need.
"http://www.tu-chemnitz.de/~nomssi/paszlib.html"

Regards, Madshi.
0
 
JaccoCommented:
Are there any strange characters in the string? I mean is the character range used in the strings 0..255 or something like 'A'..'Z','a'..'z','0'..'9','+-=,.:;"/?!@#$%^&*()_+'?

Regards Jacco
0
 
erajojCommented:
Hi,
What sizes of strings are we talking about here?
Using Huffman on small strings <256 chars doesn't guarantee <50% compression. Compression is not an exact science. The compression never gets better than the compressee.
Using a lookup table with entries of the most common words is an approach. However, it needs quite a large table to be efficient.
Provide more info!

/// John
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
zacCommented:
If you have Delphi 3 or above then you already have the solution in the info directory on the CD.  The ZLIB library is a c implementation of the LZ77 algorithm (used by zip, gzip etc).

It implements its compression as a stream and therefore should be perfect for you use.  It is free, even includes source code and the author even provided pascal interfaces to it....

When I have used it in the past I have got greater than 50% compression on largish text files > 20K (ish) but it very much depends on the data you are compressing

I hope this helps...

Zac
0
 
MadshiCommented:
Hello zac,

seems, that you didn't read my comment!?    :-(
0
 
ThesanAuthor Commented:
And we have a winner!!
To be fair, it's Madshi because he recommended the routines first.

They are indeed quite nice. The interface could be more sophisticated, but that's not even bad - no unnecessary overhead, just resonably fast and efficient block compression routines without limitation to the length (as far as I can tell - 500K were no problem).

Thanks to zac for pointing out that these routines are included with Delphi. However, those routines have a "stream-interface" that might be a bit easier to use but is more overhead and actually makes things more complicated in my specific case.

For blocks of 50 K with about 80% plain text, I get around 65% compression.

Thanks guys and sorry for the slow reply, but I didn't have time to figure out if the routines would work for me!

Madshi: Post an answer to get your points :-))
0
 
MadshiCommented:
Thank you Thesan...   :-)

sorry, zac...   :-(

Regards, Madshi.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now