<-- Previous || Up || Next -->

Compress String Function
Co Decs Class

Public Function CompressString( _
    ByVal vString As Variant _
    ) As Variant

Compress a string using whichever text compression technique can compress it the most.
This function will compress the string using either the RunLengthEncode function or SqueezeString function.

    CompressString("This is a test.") = Chr$(3) + Chr$(158) + Chr$(200) + Chr$(142) + Chr$(234) + Chr$(159) + Chr$(243) + Chr$(240) + Chr$(46)
    CompressString("ZYXWVU") = Chr$(3) + "ZYXWVU" ' #2
    CompressString("ABCCCCCDE") = Chr$(2) + "AB" + Chr$(255) + Chr$(5) + "CDE"
    CompressString(EveryCharacter) = Chr$(1) + EveryCharacter ' #4
See also:
    DecompressString Function
    RunLengthEncode Function
    SqueezeString Function
Return: This function prefixes the result string with a single character that represents the type of compression used.
The string may not be compressed if the available compression methods yield a result longer than the original string as in example #4. It will be prefixed by Chr$(1) in such cases to represent the fact that it was left in its original form.

vString: The string containing the text which is to be compressed. Function returns Null if vString is Null or cannot be fixed up to a String.

Function returns an empty string if vString is an empty string.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.