home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / mbsnbico.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  70 lines

  1. /***
  2. *mbsnbico.c - Collate n bytes of strings, ignoring case (MBCS)
  3. *
  4. *       Copyright (c) 1994-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Collate n bytes of strings, ignoring case (MBCS)
  8. *
  9. *******************************************************************************/
  10.  
  11. #ifdef _MBCS
  12.  
  13. #if defined (_WIN32)
  14. #include <awint.h>
  15. #include <mtdll.h>
  16. #endif  /* defined (_WIN32) */
  17.  
  18. #include <cruntime.h>
  19. #include <internal.h>
  20. #include <mbdata.h>
  21. #include <mbctype.h>
  22. #include <mbstring.h>
  23.  
  24.  
  25. /***
  26. * _mbsnbicoll - Collate n bytes of strings, ignoring case (MBCS)
  27. *
  28. *Purpose:
  29. *       Collates up to n bytes of two strings for lexical order.
  30. *       Strings are collated on a character basis, not a byte basis.
  31. *       Case of characters is not considered.
  32. *
  33. *Entry:
  34. *       unsigned char *s1, *s2 = strings to collate
  35. *       size_t n = maximum number of bytes to collate
  36. *
  37. *Exit:
  38. *       returns <0 if s1 < s2
  39. *       returns  0 if s1 == s2
  40. *       returns >0 if s1 > s2
  41. *
  42. *Exceptions:
  43. *
  44. *******************************************************************************/
  45.  
  46. int __cdecl _mbsnbicoll(
  47.     const unsigned char *s1,
  48.     const unsigned char *s2,
  49.     size_t n
  50.     )
  51. {
  52. #if !defined (_WIN32)
  53.         return _mbsnbicmp(s1, s2, n);
  54. #else  /* !defined (_WIN32) */
  55.         int ret;
  56.  
  57.         if (n == 0)
  58.             return 0;
  59.  
  60.         if (0 == (ret = __crtCompareStringA(__mblcid, NORM_IGNORECASE,
  61.                 s1, n, s2, n, __mbcodepage)))
  62.             return _NLSCMPERROR;
  63.  
  64.         return ret - 2;
  65.  
  66. #endif  /* !defined (_WIN32) */
  67. }
  68.  
  69. #endif  /* _MBCS */
  70.