chsvlib
chsv helper source code

◆ AllocateUTF8FromUCS()

char* Chusov::String::AllocateUTF8FromUCS ( const wchar_t *  pszRight,
std::size_t  cchRight 
)
noexcept

Allocates and returns a multibyte UTF-8 version of a wide string given in the UCS-2 (UCS-4) format.

Parameters
[in]pszRightis a pointer to an input wide string. The string need not to be zero-terminated if cchRight specifies its actual size in wide characters. On the contrary cchRight can be (size_t) -1, in which case pszRight must be zero-terminated. If a zero-terminator is found among first cchRight wide characters of the input string the conversion stops and the last part of the input string is ignored. The terminator is converted and written to the output buffer returned by the function.
[in]cchRightmay explicitly specify a length of the input wide string in characters. Or it can be (size_t) -1 in which case the length of the input must be given by the zero-terminating character.
Returns
The function returns an allocated buffer containing the converted zero-terminated multibyte string. If an error occurs the function returns NULL and sets corresponding chsvlib error code. The allocated string should be deallocated by FreeStringA function or by any other freeing function defined in chsvmem.h.
See also
FreeStringA;
AllocateAndFormatStringA;
AllocateUCSFromUTF8;
ConvertUTF8ToUCS.