Compressing a string
With Easy Compression Library you can easily compress and decompress a string.
Compressing a string.
To compress a string you need to call ECLCompressAndEncryptString function.
As the string is not encrypted the Password parameter is to be blank.
This function adds an internal header to compressed data, so you'll see an effect of compression (decreasing length of the string) only on not very short strings.
Decompressing a string.
To decompress a string you need to call ECLDecompressAndDecryptString.
Example:
var
CompStr, DecompStr: string;
begin
ECLCompressAndEncryptString('test', CompStr, '', ppmFastest);
ECLDecompressAndDecryptString(CompStr, DecompStr);
ShowMessage(DecompStr);
end;
Warning:
Set bHexFormat parameter of ECLCompressAndEncryptString to True if you plan to access the compressed string as null-terminated string (PChar).
By default compressed string can contain some CHR(0) entrances and accessing the string with PChar() will not be correct.
|