home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / mbctype.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  5KB  |  174 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  /* _MSC_VER > 1000 */
  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  /* !defined (_WIN32) && !defined (_MAC) */
  23.  
  24. #ifndef _CRTBLD
  25. /* This version of the header files is NOT for user programs.
  26.  * It is intended for use when building the C runtimes ONLY.
  27.  * The version intended for public use will not have this message.
  28.  */
  29. #error ERROR: Use of C runtime library internal header file.
  30. #endif  /* _CRTBLD */
  31.  
  32. /* include the standard ctype.h header file */
  33.  
  34. #include <ctype.h>
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif  /* __cplusplus */
  39.  
  40.  
  41. /* Define _CRTIMP */
  42.  
  43. #ifndef _CRTIMP
  44. #ifdef CRTDLL
  45. #define _CRTIMP __declspec(dllexport)
  46. #else  /* CRTDLL */
  47. #ifdef _DLL
  48. #define _CRTIMP __declspec(dllimport)
  49. #else  /* _DLL */
  50. #define _CRTIMP
  51. #endif  /* _DLL */
  52. #endif  /* CRTDLL */
  53. #endif  /* _CRTIMP */
  54.  
  55.  
  56. /* Define __cdecl for non-Microsoft compilers */
  57.  
  58. #if (!defined (_MSC_VER) && !defined (__cdecl))
  59. #define __cdecl
  60. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  61.  
  62. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  63.  
  64. #ifndef _CRTAPI1
  65. #if _MSC_VER >= 800 && _M_IX86 >= 300
  66. #define _CRTAPI1 __cdecl
  67. #else  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  68. #define _CRTAPI1
  69. #endif  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  70. #endif  /* _CRTAPI1 */
  71.  
  72.  
  73. /*
  74.  * MBCS - Multi-Byte Character Set
  75.  */
  76.  
  77. /*
  78.  * This declaration allows the user access the _mbctype[] look-up array.
  79.  */
  80. #ifndef _INTERNAL_IFSTRIP_
  81. #if defined (_DLL) && defined (_M_IX86)
  82. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  83. _CRTIMP unsigned char * __cdecl __p__mbctype(void);
  84. _CRTIMP unsigned char * __cdecl __p__mbcasemap(void);
  85. #endif  /* defined (_DLL) && defined (_M_IX86) */
  86. #endif  /* _INTERNAL_IFSTRIP_ */
  87. _CRTIMP extern unsigned char _mbctype[];
  88. _CRTIMP extern unsigned char _mbcasemap[];
  89.  
  90.  
  91. /* bit masks for MBCS character types */
  92.  
  93. #define _MS     0x01    /* MBCS single-byte symbol */
  94. #define _MP     0x02    /* MBCS punct */
  95. #define _M1     0x04    /* MBCS 1st (lead) byte */
  96. #define _M2     0x08    /* MBCS 2nd byte*/
  97.  
  98. #define _SBUP   0x10    /* SBCS upper char */
  99. #define _SBLOW  0x20    /* SBCS lower char */
  100.  
  101. /* byte types  */
  102.  
  103. #define _MBC_SINGLE     0       /* valid single byte char */
  104. #define _MBC_LEAD       1       /* lead byte */
  105. #define _MBC_TRAIL      2       /* trailing byte */
  106. #define _MBC_ILLEGAL    (-1)    /* illegal byte */
  107.  
  108. #define _KANJI_CP   932
  109.  
  110. /* _setmbcp parameter defines */
  111. #define _MB_CP_SBCS     0
  112. #define _MB_CP_OEM      -2
  113. #define _MB_CP_ANSI     -3
  114. #define _MB_CP_LOCALE   -4
  115.  
  116.  
  117. #ifndef _MBCTYPE_DEFINED
  118.  
  119. /* MB control routines */
  120.  
  121. _CRTIMP int __cdecl _setmbcp(int);
  122. _CRTIMP int __cdecl _getmbcp(void);
  123.  
  124.  
  125. /* MBCS character classification function prototypes */
  126.  
  127.  
  128. /* byte routines */
  129. _CRTIMP int __cdecl _ismbbkalnum( unsigned int );
  130. _CRTIMP int __cdecl _ismbbkana( unsigned int );
  131. _CRTIMP int __cdecl _ismbbkpunct( unsigned int );
  132. _CRTIMP int __cdecl _ismbbkprint( unsigned int );
  133. _CRTIMP int __cdecl _ismbbalpha( unsigned int );
  134. _CRTIMP int __cdecl _ismbbpunct( unsigned int );
  135. _CRTIMP int __cdecl _ismbbalnum( unsigned int );
  136. _CRTIMP int __cdecl _ismbbprint( unsigned int );
  137. _CRTIMP int __cdecl _ismbbgraph( unsigned int );
  138.  
  139. #ifndef _MBLEADTRAIL_DEFINED
  140. _CRTIMP int __cdecl _ismbblead( unsigned int );
  141. _CRTIMP int __cdecl _ismbbtrail( unsigned int );
  142. _CRTIMP int __cdecl _ismbslead( const unsigned char *, const unsigned char *);
  143. _CRTIMP int __cdecl _ismbstrail( const unsigned char *, const unsigned char *);
  144. #define _MBLEADTRAIL_DEFINED
  145. #endif  /* _MBLEADTRAIL_DEFINED */
  146.  
  147. #define _MBCTYPE_DEFINED
  148. #endif  /* _MBCTYPE_DEFINED */
  149.  
  150. /*
  151.  * char byte classification macros
  152.  */
  153.  
  154. #define _ismbbkalnum(_c)    ((_mbctype+1)[(unsigned char)(_c)] & _MS)
  155. #define _ismbbkprint(_c)    ((_mbctype+1)[(unsigned char)(_c)] & (_MS|_MP))
  156. #define _ismbbkpunct(_c)    ((_mbctype+1)[(unsigned char)(_c)] & _MP)
  157.  
  158. #define _ismbbalnum(_c) (((_ctype+1)[(unsigned char)(_c)] & (_ALPHA|_DIGIT))||_ismbbkalnum(_c))
  159. #define _ismbbalpha(_c) (((_ctype+1)[(unsigned char)(_c)] & (_ALPHA))||_ismbbkalnum(_c))
  160. #define _ismbbgraph(_c) (((_ctype+1)[(unsigned char)(_c)] & (_PUNCT|_ALPHA|_DIGIT))||_ismbbkprint(_c))
  161. #define _ismbbprint(_c) (((_ctype+1)[(unsigned char)(_c)] & (_BLANK|_PUNCT|_ALPHA|_DIGIT))||_ismbbkprint(_c))
  162. #define _ismbbpunct(_c) (((_ctype+1)[(unsigned char)(_c)] & _PUNCT)||_ismbbkpunct(_c))
  163.  
  164. #define _ismbblead(_c)  ((_mbctype+1)[(unsigned char)(_c)] & _M1)
  165. #define _ismbbtrail(_c) ((_mbctype+1)[(unsigned char)(_c)] & _M2)
  166.  
  167. #define _ismbbkana(_c)  ((_mbctype+1)[(unsigned char)(_c)] & (_MS|_MP))
  168.  
  169. #ifdef __cplusplus
  170. }
  171. #endif  /* __cplusplus */
  172.  
  173. #endif  /* _INC_MBCTYPE */
  174.