Xceed Binary Encoding Library Documentation
Xceed Binary Encoding control reference / Methods / Encode method
In This Topic
    Encode method
    In This Topic

    Description

    The Encode method encodes data entirely in memory. It can encode data in a single call, or it can be called multiple times to encode data in a streaming fashion.

    Parameters
     

    Parameter Description
    vaSource 
     
    The data to encode. All OLE automation variant types are supported, including string and byte array variants.
    bEndOfData  This parameter indicates to the library whether or not there is more data to encode.

    If you only have a single block of data to encode, set this parameter to True. The library will then immediately encode all the data provided in the vaSource parameter and return the resulting encoded data.

    If you can only provide a portion of the data to encode in the vaSource parameter and will provide more data later in a subsequent call to the Encode method, set this parameter to False. In this case, the library will encode and return as much data as possible. When the final portion of the data to encode has been provided, set the bEndOfData parameter to True. The method will then return the final portion of the encoded data.

    Return value

    The return value is a byte array variant containing the encoded data.

    Associated properties

    The EncodingFormat property allows you to specify the format of the encoded data to produce.

    Associated methods

    ToString and FromString

    Remarks

    When calling the Encode method with the bEndOfData parameter specified as False, you cannot call any other Xceed Binary Encoding control method (of the same instance of the control) until you have completed processing a stream of data by calling the Encode method with the bEndOfData parameter specified as True.

    Language-specific remarks

    With Visual Basic, it is often necessary to convert the resulting encoded data from a byte array variant to a native VB byte array before saving it or transmitting it. VB6 makes it particularly easy to do the conversion: If you have a variant named (for example) EncodedData, you can convert it to a native VB byte array with the following code:

    Visual Basic Copy Code

    Dim EncodedDataArray() As Byte
    EncodedDataArray = EncodedData

    With Microsoft Access, you can place the encoded data in either a Memo field or an OLE Object field. Using an OLE Object field in a table is the easiest: You can directly assign your data to the field and conversion is automatic. To assign the encoded data variant to a Memo field, use the "AppendChunk" function in Access.

    Declaration (DXceedBinaryEncoding) Copy Code
    HRESULT Encode
    (
      [in] VARIANT* vaSource,
      [in] VARIANT_BOOL bEndOfData,
      [out, retval] VARIANT* vaEncoded
    )
    Declaration (IXceedBinaryEncoding) Copy Code

    HRESULT Encode
    (
      [size_is][in] BYTE* pcSource,
      [in] DWORD dwSourceSize,
      [in] BOOL bEndOfData,
      [size_is][size_is][out] BYTE** ppcEncoded,
      [out, retval] DWORD* pdwEncodedSize
    )