str_extra.c

Extra string functions library for C
git clone git://git.finwo.net/lib/str_extra.c
Log | Files | Refs | README

strcasecmp.c (509B)


      1 #ifdef __cplusplus
      2 extern "C" {
      3 #endif
      4 
      5 #include "strcasecmp.h"
      6 
      7 #if defined(_WIN32) || defined(_WIN64)
      8 #include <ctype.h> // toupper, tolower
      9 
     10 int strcasecmp(const char *a, const char *b) {
     11   int ca, cb;
     12   do {
     13     // Different diacritic options with upper and lower, so merge with both
     14     ca = tolower(toupper(*(unsigned char *)a));
     15     cb = tolower(toupper(*(unsigned char *)b));
     16     a++;
     17     b++;
     18   } while(ca == cb && ca != '\0');
     19   return ca - cb;
     20 }
     21 
     22 #endif
     23 
     24 
     25 #ifdef __cplusplus
     26 } // extern "C"
     27 #endif