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 string which contains the base64 encoded text.
lpOutput
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:
Value 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 email 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. The conversion is always performed using the default system code page.

It is recommended that you use the UnicodeEncodeText function to convert a string to UTF-8 encoded text, and the UnicodeDecodeText function to convert UTF-8 encoded text to a UTF-16 or localized multi-byte string.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csncdv11.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

DecodeFile, EncodeBuffer, EncodeFile, GetMessageDigest, IsUnicodeText, UnicodeDecodeText, UnicodeEncodeText