_mbsnbcoll, _mbsnbicoll

De RAD Studio
Aller à : navigation, rechercher

Remonter à String.h - Index


Header File

mbstring.h

Category

Memory and String Manipulation Routines

Prototype

int _mbsnbcoll(const unsigned char *s1, const unsigned char *s2, maxlen);

int _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, maxlen);

Description

_mbsnbicoll is the case-insensitive version of _mbsnbcoll.

These functions collate the strings specified by arguments s1 and s2. The collation order is determined by lexicographic order as specified by the current multibyte code page. At most, maxlen number of bytes are collated.

Note: The lexicographic order is not always the same as the order of characters in the character set.

If the last byte in s1 or s2 is a leadbyte, it is not compared.

Return Value

Each of these functions return 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 case-sensitively */
   return _mbsnbcoll(left, right, (left_len > right_len) ? right_len : left_len);
 }

On error, each of these functions returns _NLSCMPERROR.