This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported in Universal Windows Platform apps.
errno_t _mbccpy_s( unsigned char *dest, size_t buffSizeInBytes, int * pCopied, const unsigned char *src ); errno_t _mbccpy_s_l( unsigned char *dest, size_t buffSizeInBytes, int * pCopied, const unsigned char *src, locale_t locale ); template <size_t size> errno_t _mbccpy_s( unsigned char (&dest)[size], int * pCopied, const unsigned char *src ); // C++ only template <size_t size> errno_t _mbccpy_s_l( unsigned char (&dest)[size], int * pCopied, const unsigned char *src, locale_t locale ); // C++ only
Size of the destination buffer.
Filled with the number of bytes copied (1 or 2 if successful). Pass NULL if you don't care about the number.
Multibyte character to copy.
Locale to use.
Zero if successful; an error code on failure. If src or dest is NULL, or if more than buffSizeinBytes bytes would be copied to dest, then the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, the functions return EINVAL and errno is set to EINVAL.
The _mbccpy_s function copies one multibyte character from src to dest. If src does not point to the lead byte of a multibyte character as determined by an implicit call to _ismbblead, then the single byte that src points to is copied. If src points to a lead byte but the following byte is 0 and thus invalid, then 0 is copied to dest, errno is set to EILSEQ, and the function returns EILSEQ.
_mbccpy_s does not append a null terminator; however, if src points to a null character, then that null is copied to dest (this is just a regular single-byte copy).
The value in pCopied is filled with the number of bytes copied. Possible values are 1 and 2 if the operation is successful. If NULL is passed in, this parameter is ignored.
|src||copied to dest||pCopied||Return value|
|lead-byte followed by non-0||lead-byte followed by non-0||2||0|
|lead-byte followed by 0||0||1||EILSEQ|
Note that the second row is just a special case of the first. Also note that the table assumes buffSizeInBytes >= pCopied.
_mbccpy_s uses the current locale for any locale-dependent behavior. _mbccpy_s_l is identical to _mbccpy_s except that _mbccpy_s_l uses the locale passed in for any locale-dependent behavior.
In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically, eliminating the need to specify a size argument. For more information, see Secure Template Overloads.
By default, this function's global state is scoped to the application. To change this, see Global state in the CRT.
Generic-Text Routine Mappings
|Tchar.h routine||_UNICODE and _MBCS not defined||_MBCS defined||_UNICODE defined|
|_tccpy_s||Maps to macro or inline function.||_mbccpy_s||Maps to macro or inline function.|
For more compatibility information, see Compatibility.