ZLibDecompress

From SCAR Divi Manual
Jump to: navigation, search

Definition

function ZLibCompress(const Str: AnsiString): AnsiString;

Availability

SCAR Divi 3.31 > Current

Description

Decompresses a given compressed string Str using the Zlib compression library. If the string is encoded with an encoding function, it has to be decoded first. If the entered string isn't a valid ZLib compressed string, the function will return an empty string. A string can be ZLib compressed with ZLibCompress.

Example

var
  Str, Decoded, Decompressed: AnsiString;

begin
  Str := 'eNpVVFlu3DAM/Q+QO/AAhu9QdAEKtEWAnIAjMR4CkuxomfP3UbI9zsd4DNsi30b+WbN' +
    'E0q20SH4Na6ailThKncitqYirUlsmJq+bFqdpIQlaZ/rRtFDkIKWx54lCr9QqbRKCpCrlswk' +
    '95K6uBbxvOTElvd2phZrVqRSSvJbJztwl+SwZrZMWRdmWUR0vIpfCM73duaBsK1TEoygQjOt' +
    'M/1oIDAqeUksOl2Dd0KFUNQReF9QsGinoDQ1n+p650EMfkjOjwQJcn0am8KaSiAPOoaIsUio' +
    'XfN8y39RU+EItruBeVWj1uk4kYB7YSWaghmaFuLkKQdXP9HcQ2p8IusXVE0pu1ndXnBSls28' +
    'RpND/rN95BTjRilUSJwkEDpg3sEo4NEycTBZyLRcA6DJVTU59S1Yerq1J3I5v8J0OonhPVeJ' +
    'mABfz/zSX0poAwKRDn7I6BerEdTUZNqCperN2tauJdx6/jTP4oQGerqbZhCPF9TRl9ZYKnIn' +
    'G6XeiOzv8oDL8FhOyikUOnGOpp37G7bQnKYT6WRX3H5IjGgHcky1wBKN0mGJtKohly/UC4Ph' +
    '7cAhGBZ/2GEoQ/YCaQ7nRvmdjfn15ffnVAB/BqSyXDPfcz/RNknC6PN+yVMXxnuCuKGC2RQ1' +
    'JTyBfvQm6YEpmem8FgkI/qMDOgT2K3gLjUd3HBUqdnheMHEDv5GFdrYqEfRFszU5H/wHFw/Z' +
    'u10GWd9QGumUz5B1D9tQ0qk0XMvI1/yf4fRec3c8cj+SaB0OLI37PwPe9YyD72F6o9KF2a97' +
    'gVx9OQ9BdfLti4OzaIYvlwobwhHEOELuJtjsDBAZ++HfsgpEfWyo9VFGvu8aw9n0EybsyV6H' +
    'CQxPnfhRd7fS5i8ZOGal6UtrHq9mgTbRkfihGSxraAPgQnW3Mhix7NXq0sLWKeSAG67GkD9y' +
    'HlcdMBEYY5QjYgRHaNAs8JDydwVBoUluUYwd1p469ZKpOF5ciXPCKu/6VxSFhOED4P24HSoQ=';
  WriteLn('Original length: ' + IntToStr(Length(Str)));
  Decoded := Base64ToStr(Str);
  WriteLn('Length after decoding: ' + IntToStr(Length(Decoded)));
  Decompressed := ZLibDecompress(Decoded);
  WriteLn('Length after decoding and decompressing: ' + IntToStr(Length(Decompressed)));
end.

Output:

Original length: 1004
Length after decoding: 752
Length after decoding and decompressing: 1598

See Also