If the UTF-8 encoded text is successfully decoded, the return value
is the number of characters copied to the string buffer. If the text
cannot be decoded, or the string buffer is not large enough to store
all of the decoded text, the function will return zero. To get
extended error information, call GetLastError.
There are two versions of this function, UnicodeDecodeTextA
which returns a localized multi-byte string and UnicodeDecodeTextW
which converts the UTF-8 encoded text to UTF-16 text. Your project
configuration typically determines which version of this function is
used by default.
If the value of the nLength parameter is larger than the
number of UTF-8 characters, the function will not check beyond
the terminating null character. If the length of the lpUtf8Text string is
unknown, specify a length of -1 and the function will decode the entire
contents of the string up to the terminating null character.
When calling UnicodeDecodeTextA to convert UTF-8
encoded text to a localized multi-byte string, it is recommended that
you specify CP_ACP (zero) as the code page value unless you know it
contains Unicode characters that cannot be represented using the
default ANSI code page. Using CP_ACP will ensure the UTF-8
text is decoded using the current locale and
language settings.
When calling UnicodeDecodeTextW to convert UTF-8
encoded text to UTF-16 text, the code page parameter is ignored and
should always be a value of zero.
This function performs a strict check on the UTF-8 encoded text and
will fail if the encoding is malformed, or in the case of being
converted to a multi-byte string, if it cannot be decoded using the
specified code page. It will not simply replace invalid character
sequences with a default character.