$GZip: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
(Automatically generated page update)
 
(17 intermediate revisions by 3 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Compress a longstring with GZip</span>
<span class="pageSubtitle">Compress a longstring with GZip</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is the <var>[[Gzip (String function)|Gzip]]</var> method.</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is the <var>[[Gzip (String function)|Gzip]]</var> method.</p>


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.  
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.  
Line 9: Line 9:


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" />%lstrc = $GZip(%lstr, level, filename, datetime)
<p class="syntax"><span class="term">%lstrc</span> = <span class="literal">$GZip</span>(<span class="term">%lstr</span>, <span class="term">level</span>, <span class="term">filename</span>, <span class="term">datetime</span>)
<section end="syntax" /></p>
</p>


===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>%lstrc</th>  
<tr><th>%lstrc</th>  
<td>The returned longstring.</td></tr>
<td>The returned longstring.</td></tr>
<tr><th>%lstrc</th>  
 
<tr><th>%lstr</th>  
<td>The longstring to be compressed. This argument is required. </td></tr>
<td>The longstring to be compressed. This argument is required. </td></tr>


Line 55: Line 56:
In the following example,  
In the following example,  
<code>%lsgz</code> is set to the compressed version of the given string:
<code>%lsgz</code> is set to the compressed version of the given string:
<p class="code">%ls = 'I''ve got sunshine on a cloudy day'
<p class="code">%ls = 'I&apos;&apos;ve got sunshine on a cloudy day'
%dt = $date and $time
%dt = $date and $time
%lsgz = $GZip(%ls, 6, 'mygirl.txt', %dt)
%lsgz = $GZip(%ls, 6, 'mygirl.txt', %dt)
</p>
</p>


'''Note:''' No other string or longstring functions (except copy) can be usefully performed on the compressed string until it is decompressed with <var>[[$GunZip]]</var>.
<p class="note"><b>Note:</b> No other string or longstring functions (except copy) can be usefully performed on the compressed string until it is decompressed with <var>[[$GunZip]]</var>.</p>


==Products authorizing {{PAGENAMEE}}==  
==Products authorizing {{PAGENAMEE}}==  
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[List of $functions|Sirius Functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>


</ul>
</ul>

Latest revision as of 22:51, 20 September 2018

Compress a longstring with GZip

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is the Gzip method.

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

%lstrc = $GZip(%lstr, level, filename, datetime)

Syntax terms

%lstrc The returned longstring.
%lstr The longstring to be compressed. This argument is required.
level 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. The type values are described below in "Compressions options".
filename This 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.
datetime This optional string contains the file modification date and time. This must be a string in the format YYYY-MM-DD HH:MI:SS or YY-MM-DD HH:MI:SS If a two-digit year is supplied, the CENTSPAN value used is 75.

Compressions options

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.

Usage notes

  • 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.

Examples

In the following example, %lsgz is set to the compressed version of the given string:

%ls = 'I''ve got sunshine on a cloudy day' %dt = $date and $time %lsgz = $GZip(%ls, 6, 'mygirl.txt', %dt)

Note: No other string or longstring functions (except copy) can be usefully performed on the compressed string until it is decompressed with $GunZip.

Products authorizing $GZip