For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported with /ZW.
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
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
errno is set to
_mbccpy_s function copies one multibyte character from
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
errno is set to
EILSEQ, and the function returns
_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.
|copied to ||Return value|
|lead-byte followed by non-0||lead-byte followed by non-0||2||0|
|lead-byte followed by 0||0||1|
Note that the second row is just a special case of the first. Also note that the table assumes
_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.
|Tchar.h routine||_UNICODE and _MBCS not defined||_MBCS defined||_UNICODE defined|
|Maps to macro or inline function.||Maps to macro or inline function.|
For more compatibility information, see Compatibility.