STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mbctype.h
Go to the documentation of this file.
1 /***
2 *mbctype.h - MBCS character conversion macros
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 *Purpose:
7 * Defines macros for MBCS character classification/conversion.
8 *
9 * [Public]
10 *
11 ****/
12 
13 #pragma once
14 
15 #ifndef _INC_MBCTYPE
16 #define _INC_MBCTYPE
17 
18 #include <crtdefs.h>
19 #include <ctype.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 
26 /*
27  * MBCS - Multi-Byte Character Set
28  */
29 
30 /*
31  * This declaration allows the user access the _mbctype[] look-up array.
32  */
33 #ifdef _CRTBLD
34 #if defined (_DLL) && defined (_M_IX86)
35 /* Retained for compatibility with VC++ 5.0 and earlier versions */
36 _Check_return_ _CRTIMP unsigned char * __cdecl __p__mbctype(void);
37 _Check_return_ _CRTIMP unsigned char * __cdecl __p__mbcasemap(void);
38 #endif /* defined (_DLL) && defined (_M_IX86) */
39 #endif /* _CRTBLD */
40 
41 #if !defined (_M_CEE_PURE)
42 /* No data exports in pure code */
43 _CRTIMP extern unsigned char _mbctype[];
44 _CRTIMP extern unsigned char _mbcasemap[];
45 #else /* !defined (_M_CEE_PURE) */
46 _Check_return_ _CRTIMP unsigned char * __cdecl __p__mbctype(void);
47 _Check_return_ _CRTIMP unsigned char * __cdecl __p__mbcasemap(void);
48 #define _mbctype (__p__mbctype())
49 #define _mbcasemap (__p__mbcasemap())
50 #endif /* !defined (_M_CEE_PURE) */
51 
52 #ifdef _CRTBLD
53 extern pthreadmbcinfo __ptmbcinfo;
54 extern int __globallocalestatus;
55 extern int __locale_changed;
56 extern struct threadmbcinfostruct __initialmbcinfo;
57 pthreadmbcinfo __cdecl __updatetmbcinfo(void);
58 #endif /* _CRTBLD */
59 
60 /* bit masks for MBCS character types */
61 
62 #define _MS 0x01 /* MBCS single-byte symbol */
63 #define _MP 0x02 /* MBCS punct */
64 #define _M1 0x04 /* MBCS 1st (lead) byte */
65 #define _M2 0x08 /* MBCS 2nd byte*/
66 
67 #define _SBUP 0x10 /* SBCS upper char */
68 #define _SBLOW 0x20 /* SBCS lower char */
69 
70 /* byte types */
71 
72 #define _MBC_SINGLE 0 /* valid single byte char */
73 #define _MBC_LEAD 1 /* lead byte */
74 #define _MBC_TRAIL 2 /* trailing byte */
75 #define _MBC_ILLEGAL (-1) /* illegal byte */
76 
77 #define _KANJI_CP 932
78 
79 /* _setmbcp parameter defines */
80 #define _MB_CP_SBCS 0
81 #define _MB_CP_OEM -2
82 #define _MB_CP_ANSI -3
83 #define _MB_CP_LOCALE -4
84 
85 
86 #ifndef _MBCTYPE_DEFINED
87 
88 /* MB control routines */
89 
90 _CRTIMP int __cdecl _setmbcp(_In_ int _CodePage);
91 _CRTIMP int __cdecl _getmbcp(void);
92 
93 
94 /* MBCS character classification function prototypes */
95 
96 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
97 
98 /* byte routines */
99 _Check_return_ _CRTIMP int __cdecl _ismbbkalnum( _In_ unsigned int _C );
101 _Check_return_ _CRTIMP int __cdecl _ismbbkana( _In_ unsigned int _C );
103 _Check_return_ _CRTIMP int __cdecl _ismbbkpunct( _In_ unsigned int _C );
105 _Check_return_ _CRTIMP int __cdecl _ismbbkprint( _In_ unsigned int _C );
107 _Check_return_ _CRTIMP int __cdecl _ismbbalpha( _In_ unsigned int _C );
109 _Check_return_ _CRTIMP int __cdecl _ismbbpunct( _In_ unsigned int _C );
111 _Check_return_ _CRTIMP int __cdecl _ismbbblank( _In_ unsigned int _C );
113 _Check_return_ _CRTIMP int __cdecl _ismbbalnum( _In_ unsigned int _C );
115 _Check_return_ _CRTIMP int __cdecl _ismbbprint( _In_ unsigned int _C );
117 _Check_return_ _CRTIMP int __cdecl _ismbbgraph( _In_ unsigned int _C );
119 
120 #ifndef _MBLEADTRAIL_DEFINED
121 _Check_return_ _CRTIMP int __cdecl _ismbblead( _In_ unsigned int _C);
122 _Check_return_ _CRTIMP int __cdecl _ismbblead_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale );
123 _Check_return_ _CRTIMP int __cdecl _ismbbtrail( _In_ unsigned int _C);
125 _Check_return_ _CRTIMP int __cdecl _ismbslead(_In_reads_z_(_Pos - _Str+1) const unsigned char * _Str, _In_z_ const unsigned char * _Pos);
126 _Check_return_ _CRTIMP int __cdecl _ismbslead_l(_In_reads_z_(_Pos - _Str+1) const unsigned char * _Str, _In_z_ const unsigned char * _Pos, _In_opt_ _locale_t _Locale);
127 _Check_return_ _CRTIMP int __cdecl _ismbstrail(_In_reads_z_(_Pos - _Str+1) const unsigned char * _Str, _In_z_ const unsigned char * _Pos);
128 _Check_return_ _CRTIMP int __cdecl _ismbstrail_l(_In_reads_z_(_Pos - _Str+1) const unsigned char * _Str, _In_z_ const unsigned char * _Pos, _In_opt_ _locale_t _Locale);
129 
130 #define _MBLEADTRAIL_DEFINED
131 #endif /* _MBLEADTRAIL_DEFINED */
132 
133 #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
134 
135 #define _MBCTYPE_DEFINED
136 #endif /* _MBCTYPE_DEFINED */
137 
138 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
139 
140 /*
141  * char byte classification macros
142  */
143 
144 #if defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL)
145 #define _ismbbkalnum(_c) ((_mbctype+1)[(unsigned char)(_c)] & _MS)
146 #define _ismbbkprint(_c) ((_mbctype+1)[(unsigned char)(_c)] & (_MS|_MP))
147 #define _ismbbkpunct(_c) ((_mbctype+1)[(unsigned char)(_c)] & _MP)
148 
149 #define _ismbbalnum(_c) (((_pctype)[(unsigned char)(_c)] & (_ALPHA|_DIGIT))||_ismbbkalnum(_c))
150 #define _ismbbalpha(_c) (((_pctype)[(unsigned char)(_c)] & (_ALPHA))||_ismbbkalnum(_c))
151 #define _ismbbgraph(_c) (((_pctype)[(unsigned char)(_c)] & (_PUNCT|_ALPHA|_DIGIT))||_ismbbkprint(_c))
152 #define _ismbbprint(_c) (((_pctype)[(unsigned char)(_c)] & (_BLANK|_PUNCT|_ALPHA|_DIGIT))||_ismbbkprint(_c))
153 #define _ismbbpunct(_c) (((_pctype)[(unsigned char)(_c)] & _PUNCT)||_ismbbkpunct(_c))
154 #define _ismbbblank(_c) (((_c) == '\t') ? _BLANK : (_pctype)[(unsigned char)(_c)] & _BLANK)
155 
156 #define _ismbblead(_c) ((_mbctype+1)[(unsigned char)(_c)] & _M1)
157 #define _ismbbtrail(_c) ((_mbctype+1)[(unsigned char)(_c)] & _M2)
158 
159 #define _ismbbkana(_c) ((_mbctype+1)[(unsigned char)(_c)] & (_MS|_MP))
160 #endif /* defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) */
161 
162 #ifdef _CRTBLD
163 #define _ismbbalnum_l(_c, pt) ((((pt)->locinfo->pctype)[(unsigned char)(_c)] & \
164  (_ALPHA|_DIGIT)) || \
165  (((pt)->mbcinfo->mbctype+1)[(unsigned char)(_c)] & _MS))
166 #define _ismbbalpha_l(_c, pt) ((((pt)->locinfo->pctype)[(unsigned char)(_c)] & \
167  (_ALPHA)) || \
168  (((pt)->mbcinfo->mbctype+1)[(unsigned char)(_c)] & _MS))
169 #define _ismbbgraph_l(_c, pt) ((((pt)->locinfo->pctype)[(unsigned char)(_c)] & \
170  (_PUNCT|_ALPHA|_DIGIT)) || \
171  (((pt)->mbcinfo->mbctype+1)[(unsigned char)(_c)] & (_MS|_MP)))
172 #define _ismbbprint_l(_c, pt) ((((pt)->locinfo->pctype)[(unsigned char)(_c)] & \
173  (_BLANK|_PUNCT|_ALPHA|_DIGIT)) || \
174  (((pt)->mbcinfo->mbctype + 1)[(unsigned char)(_c)] & (_MS|_MP)))
175 #define _ismbbpunct_l(_c, pt) ((((pt)->locinfo->pctype)[(unsigned char)(_c)] & _PUNCT) || \
176  (((pt)->mbcinfo->mbctype+1)[(unsigned char)(_c)] & _MP))
177 #define _ismbbblank_l(_c, pt) (((_c) == '\t') ? _BLANK : (((pt)->locinfo->pctype)[(unsigned char)(_c)] & _BLANK) || \
178  (((pt)->mbcinfo->mbctype+1)[(unsigned char)(_c)] & _MP))
179 #define _ismbblead_l(_c, p) ((p->mbcinfo->mbctype + 1)[(unsigned char)(_c)] & _M1)
180 #define _ismbbtrail_l(_c, p) ((p->mbcinfo->mbctype + 1)[(unsigned char)(_c)] & _M2)
181 #endif /* _CRTBLD */
182 
183 #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
184 
185 #ifdef __cplusplus
186 }
187 #endif /* __cplusplus */
188 
189 #endif /* _INC_MBCTYPE */
_Check_return_ _CRTIMP int __cdecl _ismbbkprint(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbalpha_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbalnum_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbkpunct_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbtrail(_In_ unsigned int _C)
_CRTIMP unsigned char _mbcasemap[]
struct threadmbcinfostruct * pthreadmbcinfo
Definition: crtdefs.h:2075
_Check_return_ _CRTIMP int __cdecl _ismbbtrail_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbstrail_l(_In_reads_z_(_Pos-_Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos, _In_opt_ _locale_t _Locale)
#define _CRTIMP
Definition: crtdefs.h:23
_Check_return_ _CRTIMP int __cdecl _ismbstrail(_In_reads_z_(_Pos-_Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos)
_Check_return_ _CRTIMP int __cdecl _ismbbkana_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbprint(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbkprint_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_CRTIMP int __cdecl _getmbcp(void)
_Check_return_ _CRTIMP int __cdecl _ismbslead_l(_In_reads_z_(_Pos-_Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbalnum(_In_ unsigned int _C)
_CRTIMP unsigned char _mbctype[]
_Check_return_ _CRTIMP int __cdecl _ismbbkana(_In_ unsigned int _C)
#define _In_reads_z_(size)
Definition: sal.h:329
#define _Check_return_
Definition: sal.h:563
#define _In_z_
Definition: sal.h:319
#define _In_
Definition: sal.h:314
_Check_return_ _In_z_ const char * _Locale
Definition: locale.h:117
_Check_return_ _CRTIMP int __cdecl _ismbbgraph(_In_ unsigned int _C)
#define _In_opt_
Definition: sal.h:315
_Check_return_ _CRTIMP int __cdecl _ismbblead_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbkpunct(_In_ unsigned int _C)
_In_ wchar_t _C
Definition: wchar.h:1295
_Check_return_ _CRTIMP int __cdecl _ismbbalpha(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbgraph_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbblead(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbpunct(_In_ unsigned int _C)
_CRTIMP int __cdecl _setmbcp(_In_ int _CodePage)
_Check_return_ _CRTIMP int __cdecl _ismbbblank_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbpunct_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbkalnum_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbprint_l(_In_ unsigned int _C, _In_opt_ _locale_t _Locale)
_Check_return_ _CRTIMP int __cdecl _ismbbkalnum(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbslead(_In_reads_z_(_Pos-_Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos)
_Check_return_ _CRTIMP int __cdecl _ismbbblank(_In_ unsigned int _C)
Definition: crtdefs.h:2078