$GZip: Difference between revisions
(Created page with "{{DISPLAYTITLE:$GZip}} <span class="pageSubtitle"><section begin="desc" />Compress a longstring with GZIP<section end="desc" /></span> <p class="warning">Most Sirius $functions ...") |
m (1 revision) |
(No difference)
|
Revision as of 15:45, 31 January 2011
<section begin="desc" />Compress a longstring with GZIP<section end="desc" />
Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is to be entered.
This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. The GZIP format is described in RFC 1952. It is very effective with HTML and XML data.
The $GZip function accepts four arguments and returns a longstring result.
Syntax
<section begin="syntax" /> %lstrc = $GZip(%lstr, level, filename, datetime) <section end="syntax" />
The first argument is the longstring to be compressed, and it is required.
The second argument is a string or integer value that describes the type of compression to perform on the longstring. This argument is optional; if it is not specified, DYNAMIC (type 2) compression is used. Valid options and their meanings are:
FIXED | Indicates that compression is done with fixed codes. The fixed code tables used for compression (defined as part of RFC 1951) are somewhat optimized for ASCII character data, but slightly decrease the amount of CPU required to perform compression. Also, since the codes are already defined as part of the specification, they are not included in the compressed data. |
---|---|
DYNAMIC | Indicates that the compression code tables are generated based on the input data. Dynamic tables typically provide somewhat better compression on most types of data. There is a very slight CPU overhead in computing the frequencies of byte values in the input data. Also, since the code tables are dynamic, they are included as part of the compressed data. This will increase the size of the compressed longstring, but these tables are small, since they are also stored in a compressed form. |
0-6 | Indicates the type of compression used. Specifying 0 indicates the default should be used, which is the same as specifying DYNAMIC. Values 1 through 6 specify a tradeoff in speed and compression factor: The value 1 uses the least CPU and compresses the string quickly; the value 6 uses the most CPU but gets the best compression. Higher numbers may increase the CPU considerably without significantly improving the compression. |
The third argument, an optional string, contains the internal name of the compressed string. Decompression programs will use this name for the output file when the string is un-zipped. The maximum length of the filename is 32 bytes.
The fourth argument, an optional string, contains the file modification date and time. This must be a string in the format YYYY-MM-DD HH:MI:SS:elit. or
- If an invalid option is passed, or if compression is not enabled for the current run, the request is cancelled.
- The NCMPBUF parameter must be set by User 0 before the $GZip function can be used. If $GZip is called with NCMPBUF = 0, the request is cancelled.
- As with any compression scheme, it is possible that a particular string will become longer after compression. This would happen, for example, if a deflated string were passed to $GZip.
- Short strings (less than 128 bytes) will typically compress better with the FIXED option.
- Multiple files are not currently supported. In the following example,
- .%lsgz is set to the compressed version of the given string:
%ls = 'Ive got sunshine on a cloudy day' %dt = $date and $time %lsgz = $GZip(%ls, 6, 'mygirl.txt', %dt)
No other string or longstring functions (except copy) can be usefully performed on the compressed string until it is decompressed with $GunZip (:hdref reftxt=$GUNZIP refid=$gunzip.). :enote