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

  1. /***
  2. *mbscoll.c - Collate MBCS strings
  3. *
  4. *       Copyright (c) 1994-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Collate MBCS strings
  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 <string.h>
  23. #include <mbstring.h>
  24.  
  25.  
  26. /***
  27. * _mbscoll - Collate MBCS strings
  28. *
  29. *Purpose:
  30. *       Collates two strings for lexical order.   Strings
  31. *       are collated on a character basis, not a byte basis.
  32. *
  33. *Entry:
  34. *       char *s1, *s2 = strings to collate
  35. *
  36. *Exit:
  37. *       returns <0 if s1 < s2
  38. *       returns  0 if s1 == s2
  39. *       returns >0 if s1 > s2
  40. *
  41. *Exceptions:
  42. *
  43. *******************************************************************************/
  44.  
  45. int __cdecl _mbscoll(
  46.     const unsigned char *s1,
  47.     const unsigned char *s2
  48.     )
  49. {
  50. #if !defined (_WIN32)
  51.         return _mbscmp(s1, s2);
  52. #else  /* !defined (_WIN32) */
  53.         int ret;
  54.  
  55.         if (0 == (ret = __crtCompareStringA(__mblcid, 0,
  56.                 s1, -1, s2, -1, __mbcodepage)))
  57.             return _NLSCMPERROR;
  58.  
  59.         return ret - 2;
  60.  
  61. #endif  /* !defined (_WIN32) */
  62. }
  63.  
  64. #endif  /* _MBCS */
  65.