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

  1. /***
  2. *mbsnbcol.c - Collate n bytes of two MBCS strings
  3. *
  4. *       Copyright (c) 1994-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Collate n bytes of two 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. * _mbsnbcoll(s1, s2, n) - Collate n bytes of two MBCS strings
  28. *
  29. *Purpose:
  30. *       Collates up to n bytes of two strings for lexical order.
  31. *
  32. *Entry:
  33. *       unsigned char *s1, *s2 = strings to collate
  34. *       size_t n = maximum number of bytes 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 _mbsnbcoll(
  46.     const unsigned char *s1,
  47.     const unsigned char *s2,
  48.     size_t n
  49.     )
  50. {
  51. #if !defined (_WIN32)
  52.         return _mbsnbcmp(s1, s2, n);
  53. #else  /* !defined (_WIN32) */
  54.         int ret;
  55.  
  56.         if (n == 0)
  57.             return 0;
  58.  
  59.         if (0 == (ret = __crtCompareStringA(__mblcid, 0,
  60.                 s1, n, s2, n, __mbcodepage)))
  61.             return _NLSCMPERROR;
  62.  
  63.         return ret - 2;
  64.  
  65. #endif  /* !defined (_WIN32) */
  66. }
  67.  
  68. #endif  /* _MBCS */
  69.