DecodeBuffer Function  
 
LONG WINAPI DecodeBuffer(
  LPCTSTR lpszInput,  
  LPBYTE lpOutput,  
  LONG cbOutput,  
  DWORD dwOptions  
);

The DecodeBuffer function decodes an encoded string, and stores the result in the specified buffer.

Parameters

lpszInput
A pointer to a null-terminated string which contains the base64 encoded text.
lpOutout
A pointer to a byte array buffer which is used to store the decoded data. It is recommended that the buffer be as large as the length of the encoded string.
cbOutput
A long integer which specifies the maximum number of bytes which may be stored in the buffer.
dwOptions
An unsigned integer that specifies one or more options. This parameter is constructed by using a bitwise operator with any of the following values:
Constant Description
DATA_DECODE_BASE64 Decode a string that was created using the base64 encoding algorithm. This is the encoding method that is used by most modern e-mail client software. Note that this option cannot be combined with other decoding methods.
DATA_DECODE_QUOTED Decode a string that was created using the quoted-printable encoding algorithm. Note that this option cannot be combined with the other decoding methods.
DATA_DECODE_URL Decode a string that was created using the URL encoding algorithm. Note that this option cannot be combined with the other decoding methods.
DATA_DECODE_UTF7 Decode a string that was created using the UTF-7 encoding algorithm. Note that this option cannot be combined with the other decoding methods.
DATA_DECODE_UTF8 Decode a string that was created using the UTF-8 encoding algorithm. Note that this option cannot be combined with the other decoding methods.
DATA_DECODE_COMPRESSED The data was compressed prior to being encoded, and should be expanded after the decoding has completed successfully. This option is ignored if the encoding type is not base64. This should only be used if it was specified when the data was encoded.

Return Value

If the function succeeds, it will return the number of bytes decoded and stored in the buffer. If the function fails, it will return -1. Failure typically indicates that the encoded string was corrupted or the buffer is not large enough to store the decoded data.

Remarks

The DecodeBuffer function is used to decode a block of data that was previously encoded with the EncodeBuffer function. To decode the contents of a file, it is recommended that you use the DecodeFile function instead.

If you specify either UTF-7 or UTF-8 encoding, the lpOutput parameter must point to a Unicode string and the cbOutput parameter must specify the maximum number of characters, not bytes, that can be copied into the string. The return value will be the number of Unicode characters, not bytes, that were copied into the output buffer. To convert a Unicode string into an ANSI string, use the WideCharToMultiByte function.

Requirements

Client: Requires Windows 7, Windows Vista or Windows XP.
Server: Requires Windows Server 2008 or Windows Server 2003.
Header: Include cstools7.h.
Library: Use csncdav7.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

DecodeFile, EncodeBuffer, EncodeFile