ReactOS 0.4.16-dev-822-gbcedb53
mbctype.h
Go to the documentation of this file.
1//
2// mbctype.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Functions and macros for MBCS character classification and conversion.
7//
8#pragma once
9#ifndef _INC_MBCTYPE // include guard for 3rd party interop
10#define _INC_MBCTYPE
11
12#include <corecrt.h>
13#include <ctype.h>
14
15#pragma warning(push)
16#pragma warning(disable: _UCRT_DISABLED_WARNINGS)
18
20
21
22
23// This declaration allows the user access the _mbctype[] look-up array.
24_Check_return_ _ACRTIMP unsigned char* __cdecl __p__mbctype(void);
26
27#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
28 #ifndef _CORECRT_BUILD
29 extern unsigned char _mbctype[];
30 extern unsigned char _mbcasemap[];
31 #endif
32#else
33 #define _mbctype (__p__mbctype())
34 #define _mbcasemap (__p__mbcasemap())
35#endif
36
37
38
39// Bit masks for MBCS character types:
40// Different encodings may have different behaviors, applications are discouraged
41// from attempting to reverse engineer the mechanics of the various encodings.
42#define _MS 0x01 // MBCS single-byte symbol
43#define _MP 0x02 // MBCS punctuation
44#define _M1 0x04 // MBCS (not UTF-8!) 1st (lead) byte
45#define _M2 0x08 // MBCS (not UTF-8!) 2nd byte
46
47// The CRT does not do proper linguistic casing, it is preferred that applications
48// use appropriate NLS or Globalization functions.
49#define _SBUP 0x10 // SBCS uppercase char
50#define _SBLOW 0x20 // SBCS lowercase char
51
52// Byte types
53// Different encodings may have different behaviors, use of these is discouraged
54#define _MBC_SINGLE 0 // Valid single byte char
55#define _MBC_LEAD 1 // Lead byte
56#define _MBC_TRAIL 2 // Trailing byte
57#define _MBC_ILLEGAL (-1) // Illegal byte
58
59#define _KANJI_CP 932
60
61// _setmbcp parameter defines:
62// Use of UTF-8 is encouraged
63#define _MB_CP_SBCS 0
64#define _MB_CP_OEM -2
65#define _MB_CP_ANSI -3
66#define _MB_CP_LOCALE -4
67// CP_UTF8 - UTF-8 was not permitted in earlier CRT versions
68#define _MB_CP_UTF8 65001
69
70// Multibyte control routines:
72_ACRTIMP int __cdecl _getmbcp(void);
73
74
75
76//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77//
78// Multibyte Character Classification and Conversion Functions
79//
80//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81#if _CRT_FUNCTIONS_REQUIRED
82 _Check_return_ _DCRTIMP int __cdecl _ismbbkalnum(_In_ unsigned int _C);
83 _Check_return_ _DCRTIMP int __cdecl _ismbbkana (_In_ unsigned int _C);
84 _Check_return_ _DCRTIMP int __cdecl _ismbbkpunct(_In_ unsigned int _C);
85 _Check_return_ _DCRTIMP int __cdecl _ismbbkprint(_In_ unsigned int _C);
86 _Check_return_ _DCRTIMP int __cdecl _ismbbalpha (_In_ unsigned int _C);
87 _Check_return_ _DCRTIMP int __cdecl _ismbbpunct (_In_ unsigned int _C);
88 _Check_return_ _DCRTIMP int __cdecl _ismbbblank (_In_ unsigned int _C);
89 _Check_return_ _DCRTIMP int __cdecl _ismbbalnum (_In_ unsigned int _C);
90 _Check_return_ _DCRTIMP int __cdecl _ismbbprint (_In_ unsigned int _C);
91 _Check_return_ _DCRTIMP int __cdecl _ismbbgraph (_In_ unsigned int _C);
92
103
104 // BEGIN _MBLEADTRAIL_DEFINED
105 // Lead and trail bytes do not apply correctly to all encodings, including UTF-8. Applications
106 // are recommended to use the system codepage conversion APIs and not attempt to reverse
107 // engineer the behavior of any particular encoding. Lead and trail are always FALSE for UTF-8.
108 _When_(_Ch == 0, _Post_equal_to_(0))
111
112 _When_(_Ch == 0, _Post_equal_to_(0))
115
118 _In_reads_z_(_Pos - _String + 1) unsigned char const* _String,
119 _In_z_ unsigned char const* _Pos
120 );
121
124 _In_reads_z_(_Pos - _String + 1) unsigned char const* _String,
125 _In_z_ unsigned char const* _Pos,
127 );
128
131 _In_reads_z_(_Pos - _String + 1) unsigned char const* _String,
132 _In_z_ unsigned char const* _Pos
133 );
134
137 _In_reads_z_(_Pos - _String + 1) unsigned char const* _String,
138 _In_z_ unsigned char const* _Pos,
140 );
141#endif // _CRT_FUNCTIONS_REQUIRED
142
143
144
145//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
146//
147// Unsynchronized Macro Forms of Some Classification Functions
148//
149//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150#if defined _CRT_DISABLE_PERFCRIT_LOCKS && !defined _DLL
151 #define _ismbbkalnum(_c) ((_mbctype+1)[(unsigned char)(_c)] & (_MS ))
152 #define _ismbbkprint(_c) ((_mbctype+1)[(unsigned char)(_c)] & (_MS | _MP))
153 #define _ismbbkpunct(_c) ((_mbctype+1)[(unsigned char)(_c)] & (_MP ))
154
155 #define _ismbbalnum(_c) (((_pctype)[(unsigned char)(_c)] & (_ALPHA | _DIGIT )) || _ismbbkalnum(_c))
156 #define _ismbbalpha(_c) (((_pctype)[(unsigned char)(_c)] & (_ALPHA )) || _ismbbkalnum(_c))
157 #define _ismbbgraph(_c) (((_pctype)[(unsigned char)(_c)] & (_PUNCT | _ALPHA | _DIGIT )) || _ismbbkprint(_c))
158 #define _ismbbprint(_c) (((_pctype)[(unsigned char)(_c)] & (_BLANK | _PUNCT | _ALPHA | _DIGIT)) || _ismbbkprint(_c))
159 #define _ismbbpunct(_c) (((_pctype)[(unsigned char)(_c)] & (_PUNCT )) || _ismbbkpunct(_c))
160 #define _ismbbblank(_c) (((_c) == '\t') ? _BLANK : (_pctype)[(unsigned char)(_c)] & _BLANK)
161
162 // Note that these are intended for double byte character sets (DBCS) and so UTF-8 doesn't consider either to be true for any bytes
163 // (for UTF-8 we never set _M1 or _M2 in this array)
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#endif
169
172#pragma warning(pop) // _UCRT_DISABLED_WARNINGS
173#endif // _INC_MBCTYPE
#define __cdecl
Definition: accygwin.h:79
_In_ DWORD _In_ int _Out_ LPWORD _In_ int _CodePage
#define _ismbbblank_l(_c, pt)
#define _ismbbprint_l(_c, pt)
#define _ismbblead_l(_c, p)
#define _ismbbalpha_l(_c, pt)
#define _ismbbtrail_l(_c, p)
#define _ismbbgraph_l(_c, pt)
#define _ismbbalnum_l(_c, pt)
#define _ismbbpunct_l(_c, pt)
_String
_Check_return_ _CRTIMP int __cdecl _ismbbkalnum(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbprint(_In_ unsigned int _C)
_CRTIMP unsigned char _mbctype[257]
Definition: locale.c:42
_CRTIMP unsigned char _mbcasemap[257]
Definition: stubs.c:22
_Check_return_ _CRTIMP int __cdecl _ismbbkalnum_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 _ismbbtrail(_In_ unsigned int _C)
_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 _ismbbkpunct(_In_ unsigned int _C)
_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(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbpunct(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbalpha(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbkana_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 _ismbbkprint(_In_ unsigned int _C)
_Check_return_ _CRTIMP int __cdecl _ismbbgraph(_In_ unsigned int _C)
_CRTIMP int __cdecl _setmbcp(_In_ int _CodePage)
_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 _ismbbalnum(_In_ unsigned int _C)
_CRTIMP int __cdecl _getmbcp(void)
Definition: locale.c:1474
_Check_return_ _CRTIMP int __cdecl _ismbbkprint_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)
void * __p__mbcasemap()
Definition: stubs.c:25
#define _In_z_
Definition: no_sal2.h:164
#define _Check_return_
Definition: no_sal2.h:60
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _In_reads_z_(s)
Definition: no_sal2.h:172
#define _Post_equal_to_(e)
Definition: no_sal2.h:384
#define _When_(c, a)
Definition: no_sal2.h:38
_Check_return_ wchar_t _Ch
Definition: string.h:697
_In_ size_t _In_z_ _Printf_format_string_ const char _In_ const struct tm _In_opt_ _locale_t _Locale
Definition: time.h:159
#define _DCRTIMP
Definition: corecrt.h:154
#define _ACRTIMP
Definition: corecrt.h:138
#define _UCRT_DISABLE_CLANG_WARNINGS
Definition: corecrt.h:109
#define _UCRT_RESTORE_CLANG_WARNINGS
Definition: corecrt.h:117
_UCRT_DISABLE_CLANG_WARNINGS _CRT_BEGIN_C_HEADER _Check_return_ _ACRTIMP unsigned char *__cdecl __p__mbctype(void)
Definition: ismblead.c:48
#define _CRT_END_C_HEADER
Definition: vcruntime.h:42
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:40
#define const
Definition: zconf.h:233