Deflate (String function): Difference between revisions
Jump to navigation
Jump to search
m (→See also) |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Template:String:Deflate subtitle}} | {{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. | 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. | ||
Line 8: | Line 7: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%outString</th> | <tr><th nowrap>%outString</th> | ||
<td>The resulting compressed string.</td></tr> | <td>The resulting compressed string.</td></tr> | ||
Line 15: | Line 14: | ||
<tr><th><var>FixedCode</var></th> | <tr><th><var>FixedCode</var></th> | ||
<td><var>FixedCode</var> is an optional, name required, parameter that is a <var>[[Boolean_enumeration#Using_Boolean_enumerations|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>. | <td><var>FixedCode</var> is an optional, [[Notation conventions for methods#Named parameters|name required]], parameter that is a <var>[[Boolean_enumeration#Using_Boolean_enumerations|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> | <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 they 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 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 they 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. | ||
Line 61: | Line 60: | ||
</ul> | </ul> | ||
</ul> | </ul> | ||
{{Template:String:Deflate footer}} | {{Template:String:Deflate footer}} |
Latest revision as of 21:00, 3 September 2015
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
%outString | The resulting compressed string. |
---|---|
string | The string to be compressed. |
FixedCode | FixedCode is an optional, name required, 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.
|
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. The default value for this argument 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. The default value for this argument 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, %out
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.
- Other related methods: