_mbsnbset_s, _mbsnbset_s_l
Sets the first n bytes of a multibyte-character string to a specified character. These versions of _mbsnbset, _mbsnbset_l have security enhancements, as described in Security Features in the CRT.
Important
|
|---|
|
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 _mbsnbset_s( unsigned char *str, size_t size, unsigned int c, size_t count ); errno_t _mbsnbset_s_l( unsigned char *str, size_t size, unsigned int c, size_t count, _locale_t locale ); template <size_t size> errno_t _mbsnbset_s( unsigned char (&str)[size], unsigned int c, size_t count ); // C++ only template <size_t size> errno_t _mbsnbset_s_l( unsigned char (&str)[size], unsigned int c, size_t count, _locale_t locale ); // C++ only
The _mbsnbset_s and _mbsnbset_s_l functions set, at most, the first count bytes of str to c. If count is greater than the length of str, the length of str is used instead of count. If c is a multibyte character and cannot be set entirely into the last byte that's specified by count, the last byte is padded with a blank character. _mbsnbset_s and _mbsnbset_s_l do not place a terminating null at the end of str.
_mbsnbset_s and _mbsnbset_s_l resemble _mbsnset, except that they set count bytes rather than count characters of c.
If str is NULL or count is zero, this function generates an invalid parameter exception, as described in Parameter Validation. If execution is allowed to continue, errno is set to EINVAL and the function returns NULL. Also, if c is not a valid multibyte character, errno is set to EINVAL and a space is used instead.
The output value is affected by the setting of the LC_CTYPE category setting of the locale; see setlocale, _wsetlocale for more information. The _mbsnbset_s version of this function uses the current locale for this locale-dependent behavior; the _mbsnbset_s_l version is identical except that it instead uses the locale parameter that's passed in. For more information, see Locale.
In C++, use of these functions is simplified by template overloads; the overloads can infer buffer length automatically and thereby eliminate the need to specify a size argument. For more information, see Secure Template Overloads.
The debug versions of these functions first fill the buffer with 0xFD. To disable this behavior, use _CrtSetDebugFillThreshold.
|
Tchar.h routine |
_UNICODE and _MBCS not defined |
_MBCS defined |
_UNICODE defined |
|---|---|---|---|
|
_tcsnset_s |
_strnset_s |
_mbsnbset_s |
_wcsnset_s |
|
_tcsnset_s_l |
_strnset_s _l |
_mbsnbset_s_l |
_wcsnset_s_l |
|
Routine |
Required header |
|---|---|
|
_mbsnbset_s |
<mbstring.h> |
|
_mbsnbset_s_l |
<mbstring.h> |
For more compatibility information, see Compatibility.
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
Important