Close
dtSearch Text Retrieval Engine Programmer's Reference
dtssUtf8Decode2 Function

File: dtsearch.h

Syntax
C++
ptrdiff_t DLLFUNC dtssUtf8Decode2(wchar_t * dest, ptrdiff_t cchDest, const char * toEncode, ptrdiff_t cchSource, ptrdiff_t * cchNeeded);
Parameters
Description
wchar_t * dest
Buffer to receive UTF-16 text
ptrdiff_t cchDest
Size of dest buffer in characters
ptrdiff_t cchSource
Number of bytes of UTF-8 data to convert
ptrdiff_t * cchNeeded
Pointer to interer to hold the number of UTF-16 characters needed to store the encoded result, if the buffer provided was too small.
source
UTF-8 text to convert

Number of characters in the conversion output, excluding the terminating null.

Convert UTF-8 to Unicode (UTF-16)

If the buffer provided in dest is insufficient to store the conversion result, the required buffer size will be provided in cchNeeded. 

If the buffer provided was large enough to store the result, cchNeeded will not be changed. 

To use this API efficiently, callers should initialize cchNeeded to zero, provide an output buffer that is large enough to handle the most common cases, and then check cchNeeded after the conversion is done to determine whether a larger buffer is needed. This avoids the need to call the API twice in the most common cases.