home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / mbctype.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  4KB  |  156 lines

  1. /***
  2. *mbctype.h - MBCS character conversion macros
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Defines macros for MBCS character classification/conversion.
  8. *
  9. *       [Public]
  10. *
  11. ****/
  12.  
  13. #if     _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16.  
  17. #ifndef _INC_MBCTYPE
  18. #define _INC_MBCTYPE
  19.  
  20. #if     !defined(_WIN32) && !defined(_MAC)
  21. #error ERROR: Only Mac or Win32 targets supported!
  22. #endif
  23.  
  24.  
  25. /* include the standard ctype.h header file */
  26.  
  27. #include <ctype.h>
  28.  
  29. #ifdef  __cplusplus
  30. extern "C" {
  31. #endif
  32.  
  33.  
  34. /* Define _CRTIMP */
  35.  
  36. #ifndef _CRTIMP
  37. #ifdef  _DLL
  38. #define _CRTIMP __declspec(dllimport)
  39. #else   /* ndef _DLL */
  40. #define _CRTIMP
  41. #endif  /* _DLL */
  42. #endif  /* _CRTIMP */
  43.  
  44.  
  45. /* Define __cdecl for non-Microsoft compilers */
  46.  
  47. #if     (!defined(_MSC_VER) && !defined(__cdecl))
  48. #define __cdecl
  49. #endif
  50.  
  51. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  52.  
  53. #ifndef _CRTAPI1
  54. #if    _MSC_VER >= 800 && _M_IX86 >= 300
  55. #define _CRTAPI1 __cdecl
  56. #else
  57. #define _CRTAPI1
  58. #endif
  59. #endif
  60.  
  61.  
  62. /*
  63.  * MBCS - Multi-Byte Character Set
  64.  */
  65.  
  66. /*
  67.  * This declaration allows the user access the _mbctype[] look-up array.
  68.  */
  69. _CRTIMP extern unsigned char _mbctype[];
  70. _CRTIMP extern unsigned char _mbcasemap[];
  71.  
  72.  
  73. /* bit masks for MBCS character types */
  74.  
  75. #define _MS     0x01    /* MBCS single-byte symbol */
  76. #define _MP     0x02    /* MBCS punct */
  77. #define _M1     0x04    /* MBCS 1st (lead) byte */
  78. #define _M2     0x08    /* MBCS 2nd byte*/
  79.  
  80. #define _SBUP   0x10    /* SBCS upper char */
  81. #define _SBLOW  0x20    /* SBCS lower char */
  82.  
  83. /* byte types  */
  84.  
  85. #define _MBC_SINGLE     0       /* valid single byte char */
  86. #define _MBC_LEAD       1       /* lead byte */
  87. #define _MBC_TRAIL      2       /* trailing byte */
  88. #define _MBC_ILLEGAL    (-1)    /* illegal byte */
  89.  
  90. #define _KANJI_CP   932
  91.  
  92. /* _setmbcp parameter defines */
  93. #define _MB_CP_SBCS     0
  94. #define _MB_CP_OEM      -2
  95. #define _MB_CP_ANSI     -3
  96. #define _MB_CP_LOCALE   -4
  97.  
  98.  
  99. #ifndef _MBCTYPE_DEFINED
  100.  
  101. /* MB control routines */
  102.  
  103. _CRTIMP int __cdecl _setmbcp(int);
  104. _CRTIMP int __cdecl _getmbcp(void);
  105.  
  106.  
  107. /* MBCS character classification function prototypes */
  108.  
  109.  
  110. /* byte routines */
  111. _CRTIMP int __cdecl _ismbbkalnum( unsigned int );
  112. _CRTIMP int __cdecl _ismbbkana( unsigned int );
  113. _CRTIMP int __cdecl _ismbbkpunct( unsigned int );
  114. _CRTIMP int __cdecl _ismbbkprint( unsigned int );
  115. _CRTIMP int __cdecl _ismbbalpha( unsigned int );
  116. _CRTIMP int __cdecl _ismbbpunct( unsigned int );
  117. _CRTIMP int __cdecl _ismbbalnum( unsigned int );
  118. _CRTIMP int __cdecl _ismbbprint( unsigned int );
  119. _CRTIMP int __cdecl _ismbbgraph( unsigned int );
  120.  
  121. #ifndef _MBLEADTRAIL_DEFINED
  122. _CRTIMP int __cdecl _ismbblead( unsigned int );
  123. _CRTIMP int __cdecl _ismbbtrail( unsigned int );
  124. _CRTIMP int __cdecl _ismbslead( const unsigned char *, const unsigned char *);
  125. _CRTIMP int __cdecl _ismbstrail( const unsigned char *, const unsigned char *);
  126. #define _MBLEADTRAIL_DEFINED
  127. #endif
  128.  
  129. #define _MBCTYPE_DEFINED
  130. #endif
  131.  
  132. /*
  133.  * char byte classification macros
  134.  */
  135.  
  136. #define _ismbbkalnum(_c)    ((_mbctype+1)[(unsigned char)(_c)] & _MS)
  137. #define _ismbbkprint(_c)    ((_mbctype+1)[(unsigned char)(_c)] & (_MS|_MP))
  138. #define _ismbbkpunct(_c)    ((_mbctype+1)[(unsigned char)(_c)] & _MP)
  139.  
  140. #define _ismbbalnum(_c) (((_ctype+1)[(unsigned char)(_c)] & (_ALPHA|_DIGIT))||_ismbbkalnum(_c))
  141. #define _ismbbalpha(_c) (((_ctype+1)[(unsigned char)(_c)] & (_ALPHA))||_ismbbkalnum(_c))
  142. #define _ismbbgraph(_c) (((_ctype+1)[(unsigned char)(_c)] & (_PUNCT|_ALPHA|_DIGIT))||_ismbbkprint(_c))
  143. #define _ismbbprint(_c) (((_ctype+1)[(unsigned char)(_c)] & (_BLANK|_PUNCT|_ALPHA|_DIGIT))||_ismbbkprint(_c))
  144. #define _ismbbpunct(_c) (((_ctype+1)[(unsigned char)(_c)] & _PUNCT)||_ismbbkpunct(_c))
  145.  
  146. #define _ismbblead(_c)  ((_mbctype+1)[(unsigned char)(_c)] & _M1)
  147. #define _ismbbtrail(_c) ((_mbctype+1)[(unsigned char)(_c)] & _M2)
  148.  
  149. #define _ismbbkana(_c)  ((_mbctype+1)[(unsigned char)(_c)] & (_MS|_MP))
  150.  
  151. #ifdef  __cplusplus
  152. }
  153. #endif
  154.  
  155. #endif  /* _INC_MBCTYPE */
  156.