Uncompress - Maple Help

StringTools

 Uncompress
 uncompress a string or byte sequence

 Calling Sequence Uncompress(S) Uncompress(S, n) Uncompress(S, output=f)

Parameters

 S - string, Array(datatype=integer[1]), or list(integer) n - (optional) positive integer number of bytes f - (optional) output format: string, rtable, or list

Description

 • The Uncompress(S) command takes the given string, byte list, or integer[1] array and decompresses it back into its original expanded format.
 • By default the return value is an Array with datatype=integer[1].  The values in the array range from -128 to 127 as integer[1] is a signed integer format.
 • When output=list is specified the return value is a list of integers in the range 0 to 256.
 • When output=string is specified the return value is a character string.  This option should only be used when the original uncompressed form was a string.  Converting binary data to this format will be truncated if the data contains NULL bytes.
 • Both the array output format and the list output format are suitable for use with readbytes and writebytes.
 • The optional value n indicates that only the first n bytes should be uncompressed.  If n is unspecified, or if n <= 0 or if n exceeds the actual number of bytes, then all of S is uncompressed.
 • The decompression algorithm is taken from the zlib library written by Jean-loup Gailly and Mark Adler.  See http://zlib.net
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $r≔\mathrm{Compress}\left("hello world"\right)$
 ${r}{≔}\left[\begin{array}{cccccccccccccccccccc}{120}& {-100}& {-53}& {72}& {-51}& {-55}& {-55}& {87}& {40}& {-49}& {47}& {-54}& {73}& {97}& {0}& {0}& {30}& {104}& {4}& {93}\end{array}\right]$ (1)
 > $\mathrm{Uncompress}\left(r,'\mathrm{output}'='\mathrm{string}'\right)$
 ${"hello world"}$ (2)