_mbsnbicmp, _mbsnbicmp_l

Compares n bytes of two multibyte-character strings, and ignores case.

Important

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.

Syntax

int _mbsnbicmp(
   const unsigned char *string1,
   const unsigned char *string2,
   size_t count
);

Parameters

string1, string2
Null-terminated strings to compare.

count
Number of bytes to compare.

Return value

The return value indicates the relationship between the substrings.

Return value Description
< 0 string1 substring less than string2 substring.
0 string1 substring identical to string2 substring.
> 0 string1 substring greater than string2 substring.

On an error, _mbsnbicmp returns _NLSCMPERROR, which is defined in String.h and Mbstring.h.

Remarks

The _mbsnbicmp function performs an ordinal comparison of at most the first count bytes of string1 and string2. The comparison is performed by converting each character to lowercase; _mbsnbcmp is a case-sensitive version of _mbsnbicmp. The comparison ends if a terminating null character is reached in either string before count characters are compared. If the strings are equal when a terminating null character is reached in either string before count characters are compared, the shorter string is lesser.

_mbsnbicmp is similar to _mbsnbcmp, except that it compares strings up to count bytes instead of by characters.

Two strings containing characters located between 'Z' and 'a' in the ASCII table ('[', '\', ']', '^', '_', and '`') compare differently, depending on their case. For example, the two strings "ABCDE" and "ABCD^" compare one way if the comparison is lowercase ("abcde" > "abcd^") and the other way ("ABCDE" < "ABCD^") if it's uppercase.

_mbsnbicmp recognizes multibyte-character sequences according to the multibyte code page currently in use. It isn't affected by the current locale setting.

If either string1 or string2 is a null pointer, _mbsnbicmp invokes the invalid parameter handler as described in Parameter validation. If execution is allowed to continue, the function returns _NLSCMPERROR and sets errno to EINVAL.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Generic-text routine mappings

Tchar.h routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined
_tcsnicmp _strnicmp _mbsnbicmp _wcsnicmp
_tcsnicmp_l _strnicmp_l _mbsnbicmp_l _wcsnicmp_l

Requirements

Routine Required header
_mbsnbicmp <mbstring.h>

For more compatibility information, see Compatibility.

Example

See the example for _mbsnbcmp, _mbsnbcmp_l.

See also

String manipulation
_mbsnbcat, _mbsnbcat_l
_mbsnbcmp, _mbsnbcmp_l
_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_l