Internet Direct (Indy) Version 9.0.2 Beta
TIdEncoder3to4.Encode
Implements the encoding algorithm used to represent arbitrary octet sequences in the 7-bit US-ASCII character set.

function Encode(ASrcStream: TStream; const ABytes: Integer): string; override;
Parameters
ASrcStream: TStream
Stream containing the values to be encoded.

const ABytes: Integer = MaxInt
Number of bytes in ASrcStream to be encoded. Default value is MaxInt.

Returns
String - Encoded values for data in the input stream.

Description
Encode is an overridden String function in TIdEncoder3to4 that reimplements the inherited function to provide the encoding algorithm used to represent arbitrary octet sequences in the 7-bit US-ASCII character set.

ASrcStream represent a TStream descendant that contains the values to be encoded. Note: Encode does not reset the position of ASrcStream prior to or following the process of reading values from the stream.

ABytes is an Integer that represents the number of bytes in ASrcStream to be encoded. The default value for ABytes is MaxInt. If a value other than MaxInt is specified, ABytes must be a multiple of 3 or an EIdException will be raised with the RSUnevenSizeInEncodeStream message. When ABytes contains the value MaxInt, the user-defined FillChar will be appended to the input stream until the length is the required 3 bytes.

Encode calls the EncodeUnit method using the 3 bytes values read from the stream to generate the encoded value written to the result String.