RAD Studio
ContentsIndex
PreviousUpNext
strcoll,_stricoll, _mbscoll, _mbsicoll, wcscoll, _wcsicoll

Header File 

string.h, mbstring.h 

Category 

Memory and String Manipulation Routines 

Prototype 

int strcoll(const char *s1, const char *s2); 

int wcscoll(const wchar_t *s1, const wchar_t *s2); 

int _stricoll(const char *s1, const char *s2); 

int _wcsicoll(const wchar_t *s1, wconst_t char *s2); 

int _mbscoll(const unsigned char *s1, const unsigned char *s2); 

int _mbsicoll(const unsigned char *s1, const unsigned char *s2); 

Description 

Compares two strings. 

strcoll compares the string pointed to by s1 to the string pointed to by s2, according to the current locale's LC_COLLATE category. 

_stricoll performs like strcoll but is not case sensitive.

Note: Note
_stricoll does not compare string according to the current locale's LC_COLLATE category. _stricoll gives you a stricmp. The required collation is obtained by calling _lstricoll, or just plain stricoll (which maps to _lstricoll). 

The real collation (_lstricoll) returns -1, 0 or 1, whereas _stricoll does a codepoint comparison, and returns < 0, 0 or > 0. 

Return Value  

less than s2 
< 0 
the same as s2 
== 0 
greater than s2 
> 0 

Example

#include <stdio.h>
#include <string.h>
int main(void)
{
   char *two = "International";
   char *one = "Borland";
   int check;
   check = strcoll(one, two);
   if (check == 0)
      printf("The strings are equal\n");
   if (check <  0)
      printf("%s comes before %s\n", one, two);
   if (check >  0)
      printf("%s comes before %s\n", two, one);
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
strcoll 
_stricoll 
 
 
 
_mbscoll 
 
 
 
_mbsicoll 
 
 
 
wcscoll 
 
_wcsicoll 
 
 
 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!