Topic Path: Symbol Reference > Classes > TIdEncoder3to4 Class > TIdEncoder3to4 Methods > Encode Method
ContentsIndexHome
PreviousUpNext
TIdEncoder3to4.Encode Method

Implements the encoding algorithm used to represent arbitrary octet sequences in the 7-bit US-ASCII character set.

function Encode(
    ASrcStream: TIdStream; 
    const ABytes: Integer = MaxInt
): string; override;
Parameters 
Description 
ASrcStream 
Stream containing the values to be encoded.
 
ABytes 
Number of bytes in the stream to be encoded. Default value is MaxInt. 

String - Encoded values for data in the input stream.

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

ASrcStream represents the TIdStream descendant that contains the values to be encoded. 

ABytes is an Integer that represents the number of bytes in ASrcStream to be encoded. The default value for ABytes is MaxInt. 

Encode allocates an internal buffer with the size indicted in ABytes to read values from the input stream. If ABytes is larger than than the remaining contents in the stream, the smaller of the two values is used to determine the internal buffer size. 

Encode calls the ReadBytes method in TIdStreamHelper read the indicated number of bytes into the internal buffer. The EncodeIdBytes method is called to execute the actual encoding algorithm using the internal buffer. The return value for the method is extracted from the encoded values using BytesToString

Encode returns an empty string ('') when there is no remaining content in the stream as indicated by its' size and position methods. 

Please note that Encode does not reset the position of the stream in ASrcStream prior to or following the process of reading values from the stream.

TIdBytes 

TIdStreamHelper.ReadBytes 

EncodeIdBytes 

BytesToString

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.