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

Run Length Encode Printable Function
Co Decs Class

Public Function RunLengthEncodePrintable( _
    ByVal vValue As Variant _
    ) As Variant

Encode a string by replacing repeated runs of characters with a run length code.
Accepts a string containing ASCII values between 0 and 255 and returns a run-length-encoded string whose characters all have ASCII values within the range from 32 to 126 inclusive.

Examples:
    RunLengthEncodePrintable("One" + vbCrLf + Chr$(9) + "Two") = "One}-}*})Two"
    RunLengthEncodePrintable("This is a test.") = "This is a test."
See also:
    RunLengthDecodePrintable Function
    RunLengthEncode Function
This function is mainly used to represent strings containing "non-printable" characters using only "printable" characters, such as certain Visual Basic string expressions which must contain characters that Microsoft recommends should not appear in Visual Basic nor VBA Modules.
Algorithm: Characters with the ASCII value on the left are replaced by the string on the right.
    0..31:    Chr$(125) + Chr$(N + 32)
    32..123:  Chr$(N)
    124..183: Chr$(125) + Chr$(N - 60)
    183..255: Chr$(126) + Chr$(N - 151)
vValue: The string that is to be run-length encoded into a "printable" string. Function returns Null if vValue is Null or cannot be fixed up to a String.

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