_mbsnbicmp
Remonter à String.h - Index
Header File
mbstring.h
Category
Memory and String Manipulation Routines
Prototype
int _mbsnbicmp(const unsigned char *s1, const unsigned char s2, size_t maxlen);
Description
_mbsnbicmp ignores case while making a comparison of s1 and s2 for no more than maxlen bytes. It starts with the first byte in each string and continues with subsequent bytes until the corresponding bytes differ or until it has examined maxlen bytes.
_mbsnbicmp is not case sensitive.
_mbsnbicmp is not affected by locale.
_mbsnbicmp compares bytes based on the current multibyte code page.
Return Value
- _mbsnbicmp returns an integer value based on the result of comparing s1 (or part of it) to s2 (or part of it):
- < 0 if s1 is less than s2
- == 0 if s1 is the same as s2
- > 0 if s1 is greater than s2
Example
#include <mbstring.h>
/* This function is used in qsort to sort two arrays of strings */
int qsort_func(char* left, char* right)
{
/* Obtain the lengths of both strings */
int left_len = strlen(left);
int right_len = strlen(right);
/* Compare the two strings by case and locale-insensitively */
return _mbsnbicmp(left, right, (left_len > right_len) ? right_len : left_len);
}