Standardised compression of files and memory objects

The compression of data always plays an important role. Especially in the age of mobile data usage, people want to keep the amount of data transferred by the web pages to be displayed as small as possible. The upcoming version of conzept 16 will be expanded to include functions with which the content of memory objects and external files can be compressed using standardised methods.

New commands

The two functions MemCompress() and FsiFileCompress() are available for compression and MemUncompress() and FsiFileUncompress() for decompression.

The following formats are supported for compression:

The ZLIB and GZIP formats are based on the DEFLATE format. Sie wurden um einen definierten Header- und Footer-Bereich erweitert. Both formats also contain a checksum, which is used to check the consistency of the data when unpacking. None of the three formats contain an archive function (comparable to ZIP or RAR). They are purely for compressing individual files.
The respective format is specified by the constants _ComprFmtDeflate, _ComprFmtZlib and _ComprFmtGzip. In addition, a compression level between 0 (no compression) and 9 (maximum compression) or the standard level _ComprLvlDefault can be specified.

Neither the format nor the compression level needs to be specified for decompression. The algorithm recognizes the format automatically.


Modern web browsers support compression methods. The list of supported methods is sent to the web server in header entry “Accept-Encoding” with every request. If the conzept 16 SOA service is used to prepare data for a web browser, the data can be compressed as follows:

// Query and evaluate the "Accept-Encoding" HTTP header field
tEncoding # SysHTTP:HTTP.ReqHeaderGet('Accept-Encoding');
if (tEncoding != '')
  if (tEncoding =* '*gzip*')
    // Compression of the complete data of the memory object with GZIP
    // at the maximum level
    gMem->MemCompress(_ComprFmtGzip, 9);
    SysHTTP:HTTP.RspHeaderSet('Content-Encoding', 'gzip');
  else if (tEncoding =* '*deflate*')
    // Compression of the complete data of the memory object with DEFLATE
    // at the standard level
    SysHTTP:HTTP.RspHeaderSet('Content-Encoding', 'deflate');

The SysHTTP procedure from the code library was used for communication in the example.

With the new functions, a section of the source to be read out and a separate destination can also be specified. If no separate destination is specified, the source is overwritten. For example, an external file can be compressed as follows and the compressed data written to another file:

FsiFileCompress('Update.d01', _ComprFmtGzip, _ComprLvlDefault, 0, 0, 'Update.d01.gz');

In the previous example, the two zeros stand for source position and source length. If 0 is specified here, the entire file is compressed.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Get your Trial Version now!

Test yeet free of charge

Deine Trial Version - jetzt anfordern!

Teste yeet - unverbindlich und kostenfrei



Subscribe to our newsletter

WordPress Cookie Notice by Real Cookie Banner