Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize


Visual Studio .NET 2003

Compares n bytes of two multibyte character strings, ignoring case.

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


string1, string2
Null-terminated strings to compare.
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, _mbsnbcmp returns _NLSCMPERROR, which is defined in STRING.H and MBSTRING.H.


The _mbsnbicmp function lexicographically compares, at most, the first count bytes of string1 and string2. The comparison is performed without regard to case; _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 _mbsnicmp, except that it compares strings by 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 is uppercase.

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

Generic-Text Routine Mappings

TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_tcsnicmp _strnicmp _mbsnbicmp _wcsnicmp


Routine Required header Compatibility
_mbsnbicmp <mbstring.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


See the example for _mbsnbcmp.

See Also

String Manipulation Routines | _mbsnbcat | _mbsnbcmp | _stricmp | Run-Time Routines and .NET Framework Equivalents

© 2015 Microsoft