Deflate (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Automatically generated page update)
 
Line 2: Line 2:


This page is [[under construction]].
This page is [[under construction]].
==Syntax==
{{Template:String:Deflate syntax}}
{{Template:String:Deflate subtitle}}
This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. It is very effective with HTML and XML data.
==Syntax==
==Syntax==
{{Template:String:Deflate syntax}}
{{Template:String:Deflate syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%outString</th><td>string</td></tr>
<tr><th>%outString</th><td>The resulting compressed string.</td></tr>
<tr><th>string</th>
<tr><th>string</th>
<td>string</td></tr>
<td>The string to be compressed.</td></tr>
<tr><th><var>FixedCode</var></th>
<tr><th><var>FixedCode</var></th>
<td><var>Boolean</var> value<br/>This argument is optional; its default value is [[??]].</td></tr>
<td><var>FixedCode</var> is an optional, name required, <var>[[Boolean_enumeration#Using_Boolean_enumerations|Boolean]]</var> parameter that is a <var>Boolean</var> value that specifies whether the compression uses fixed codes
or is dynamic, based on the contents of the input <var class="term">string</var>.<ul>
<li>With fixed code compression (<code>fixedCode=true</code>), the 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.
<li>With dynamic compression (<code>fixedCode=false</code>), 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.
</ul>
This argument is optional; its default value is <code>false</code> (use dynamic compression).</td></tr>
<tr><th><var>LazyMatch</var></th>
<tr><th><var>LazyMatch</var></th>
<td><var>Boolean</var> value<br/>This argument is optional; its default value is [[??]].</td></tr>
<td><var>LazyMatch</var> is an optional, name required, parameter that is a <var>Boolean</var> value that specifies whether to use "lazy match" compression, as specified in RFC 1951.
This argument is optional; its default value is <code>false</code> (do not use "lazy match" compression).</td></tr>
<tr><th><var>MaxChain</var></th>
<tr><th><var>MaxChain</var></th>
<td>number<br/>This argument is optional; its default value is [[??]].</td></tr>
<td><var>MaxChain</var> is an optional, name required, parameter that is a numeric value that specifies the maximum hash chain length, as explained in RFC 1951.
This argument is optional; its default value is 0. If specified, it must be between 0 and 99, inclusive.</td></tr>
</table>
</table>
==Usage notes==
<ul>
<li>The <var>[[NCMPBUF parameter|NCMPBUF]]</var> parameter must be set to a
non-0 value during <var class="product">Model 204</var>initialization to allow
use of the <var>Deflate</var> function; otherise, invoking <var>Deflate</var>
causes request cancellation.
<li>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 $Deflate.
<li>Short strings (less than 128 bytes) typically compress better with <code>fixedCode=true</code>.
</ul>
==Examples==
In the following example, %LSTRC is set to the compressed version of the given string:
<p class="code">%out = 'How much wood could a woodchuck chuck':deflate(fixedCode=true)
</p>
==See also==
<ul>
<li><var>[[Inflate (String function)|Inflate]]</var> is used to decompress the string to its original value.
<li>[[??]]
</ul>
{{Template:String:Deflate footer}}
==Usage notes==
==Usage notes==
==Examples==
==Examples==
==See also==
==See also==
{{Template:String:Deflate footer}}
{{Template:String:Deflate footer}}

Revision as of 21:01, 31 July 2012

Compress a longstring with deflate (String class)

[Introduced in Sirius Mods 7.4]


This page is under construction.

Syntax

%outString = string:Deflate[( [FixedCode= boolean], [LazyMatch= boolean], - [MaxChain= number])]

Compress a longstring with deflate (String class)

[Introduced in Sirius Mods 7.4]

This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. It is very effective with HTML and XML data.

Syntax

%outString = string:Deflate[( [FixedCode= boolean], [LazyMatch= boolean], - [MaxChain= number])]

Syntax terms

%outStringThe resulting compressed string.
string The string to be compressed.
FixedCode FixedCode is an optional, name required, Boolean parameter that is a Boolean value that specifies whether the compression uses fixed codes or is dynamic, based on the contents of the input string.
  • With fixed code compression (fixedCode=true), the 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.
  • With dynamic compression (fixedCode=false), 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.
This argument is optional; its default value is false (use dynamic compression).
LazyMatch LazyMatch is an optional, name required, parameter that is a Boolean value that specifies whether to use "lazy match" compression, as specified in RFC 1951. This argument is optional; its default value is false (do not use "lazy match" compression).
MaxChain MaxChain is an optional, name required, parameter that is a numeric value that specifies the maximum hash chain length, as explained in RFC 1951. This argument is optional; its default value is 0. If specified, it must be between 0 and 99, inclusive.

Usage notes

  • The NCMPBUF parameter must be set to a non-0 value during Model 204initialization to allow use of the Deflate function; otherise, invoking Deflate causes request cancellation.
  • 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 $Deflate.
  • Short strings (less than 128 bytes) typically compress better with fixedCode=true.

Examples

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

%out = 'How much wood could a woodchuck chuck':deflate(fixedCode=true)

See also

  • Inflate is used to decompress the string to its original value.
  • ??

Usage notes

Examples

See also