chsvlib
chsv helper source code

◆ AllocateWideFromMBS()

wchar_t* Chusov::String::AllocateWideFromMBS ( const char *  pszRight,
std::size_t  cbRight 
)
noexcept

Allocates and returns a wide copy of a multibyte string.

Parameters
[in]pszRightis a pointer to an input multibyte string. The string need not to be zero-terminated if cbRight specifies its actual size in bytes. On the contrary cbRight can be (size_t) -1, in which case pszRight must be zero-terminated. If a zero-terminator is found among first cbRight bytes 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]cbRightmay explicitly specify a length of the input multibyte string in bytes. 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 wide string. If an error occurs the function returns NULL and sets corresponding chsvlib error code. The allocated string should be deallocated by FreeStringW function or by any other freeing function defined in chsvmem.h.
See also
FreeStringW;
AllocateAndFormatStringW;
AllocateMBSFromWide;
ConvertWideToMBS.