xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/umachine.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker *
6*0e209d39SAndroid Build Coastguard Worker *   Copyright (C) 1999-2015, International Business Machines
7*0e209d39SAndroid Build Coastguard Worker *   Corporation and others.  All Rights Reserved.
8*0e209d39SAndroid Build Coastguard Worker *
9*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
10*0e209d39SAndroid Build Coastguard Worker *   file name:  umachine.h
11*0e209d39SAndroid Build Coastguard Worker *   encoding:   UTF-8
12*0e209d39SAndroid Build Coastguard Worker *   tab size:   8 (not used)
13*0e209d39SAndroid Build Coastguard Worker *   indentation:4
14*0e209d39SAndroid Build Coastguard Worker *
15*0e209d39SAndroid Build Coastguard Worker *   created on: 1999sep13
16*0e209d39SAndroid Build Coastguard Worker *   created by: Markus W. Scherer
17*0e209d39SAndroid Build Coastguard Worker *
18*0e209d39SAndroid Build Coastguard Worker *   This file defines basic types and constants for ICU to be
19*0e209d39SAndroid Build Coastguard Worker *   platform-independent. umachine.h and utf.h are included into
20*0e209d39SAndroid Build Coastguard Worker *   utypes.h to provide all the general definitions for ICU.
21*0e209d39SAndroid Build Coastguard Worker *   All of these definitions used to be in utypes.h before
22*0e209d39SAndroid Build Coastguard Worker *   the UTF-handling macros made this unmaintainable.
23*0e209d39SAndroid Build Coastguard Worker */
24*0e209d39SAndroid Build Coastguard Worker 
25*0e209d39SAndroid Build Coastguard Worker #ifndef __UMACHINE_H__
26*0e209d39SAndroid Build Coastguard Worker #define __UMACHINE_H__
27*0e209d39SAndroid Build Coastguard Worker 
28*0e209d39SAndroid Build Coastguard Worker 
29*0e209d39SAndroid Build Coastguard Worker /**
30*0e209d39SAndroid Build Coastguard Worker  * \file
31*0e209d39SAndroid Build Coastguard Worker  * \brief Basic types and constants for UTF
32*0e209d39SAndroid Build Coastguard Worker  *
33*0e209d39SAndroid Build Coastguard Worker  * <h2> Basic types and constants for UTF </h2>
34*0e209d39SAndroid Build Coastguard Worker  *   This file defines basic types and constants for utf.h to be
35*0e209d39SAndroid Build Coastguard Worker  *   platform-independent. umachine.h and utf.h are included into
36*0e209d39SAndroid Build Coastguard Worker  *   utypes.h to provide all the general definitions for ICU.
37*0e209d39SAndroid Build Coastguard Worker  *   All of these definitions used to be in utypes.h before
38*0e209d39SAndroid Build Coastguard Worker  *   the UTF-handling macros made this unmaintainable.
39*0e209d39SAndroid Build Coastguard Worker  *
40*0e209d39SAndroid Build Coastguard Worker  */
41*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
42*0e209d39SAndroid Build Coastguard Worker /* Include platform-dependent definitions                                   */
43*0e209d39SAndroid Build Coastguard Worker /* which are contained in the platform-specific file platform.h             */
44*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
45*0e209d39SAndroid Build Coastguard Worker 
46*0e209d39SAndroid Build Coastguard Worker #include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
47*0e209d39SAndroid Build Coastguard Worker 
48*0e209d39SAndroid Build Coastguard Worker /*
49*0e209d39SAndroid Build Coastguard Worker  * ANSI C headers:
50*0e209d39SAndroid Build Coastguard Worker  * stddef.h defines wchar_t
51*0e209d39SAndroid Build Coastguard Worker  */
52*0e209d39SAndroid Build Coastguard Worker #include <stdbool.h>
53*0e209d39SAndroid Build Coastguard Worker #include <stddef.h>
54*0e209d39SAndroid Build Coastguard Worker 
55*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
56*0e209d39SAndroid Build Coastguard Worker /* For C wrappers, we use the symbol U_CAPI.                                */
57*0e209d39SAndroid Build Coastguard Worker /* This works properly if the includer is C or C++.                         */
58*0e209d39SAndroid Build Coastguard Worker /* Functions are declared   U_CAPI return-type U_EXPORT2 function-name()... */
59*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
60*0e209d39SAndroid Build Coastguard Worker 
61*0e209d39SAndroid Build Coastguard Worker /**
62*0e209d39SAndroid Build Coastguard Worker  * \def U_CFUNC
63*0e209d39SAndroid Build Coastguard Worker  * This is used in a declaration of a library private ICU C function.
64*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
65*0e209d39SAndroid Build Coastguard Worker  */
66*0e209d39SAndroid Build Coastguard Worker 
67*0e209d39SAndroid Build Coastguard Worker /**
68*0e209d39SAndroid Build Coastguard Worker  * \def U_CDECL_BEGIN
69*0e209d39SAndroid Build Coastguard Worker  * This is used to begin a declaration of a library private ICU C API.
70*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
71*0e209d39SAndroid Build Coastguard Worker  */
72*0e209d39SAndroid Build Coastguard Worker 
73*0e209d39SAndroid Build Coastguard Worker /**
74*0e209d39SAndroid Build Coastguard Worker  * \def U_CDECL_END
75*0e209d39SAndroid Build Coastguard Worker  * This is used to end a declaration of a library private ICU C API
76*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
77*0e209d39SAndroid Build Coastguard Worker  */
78*0e209d39SAndroid Build Coastguard Worker 
79*0e209d39SAndroid Build Coastguard Worker #ifdef __cplusplus
80*0e209d39SAndroid Build Coastguard Worker #   define U_CFUNC extern "C"
81*0e209d39SAndroid Build Coastguard Worker #   define U_CDECL_BEGIN extern "C" {
82*0e209d39SAndroid Build Coastguard Worker #   define U_CDECL_END   }
83*0e209d39SAndroid Build Coastguard Worker #else
84*0e209d39SAndroid Build Coastguard Worker #   define U_CFUNC extern
85*0e209d39SAndroid Build Coastguard Worker #   define U_CDECL_BEGIN
86*0e209d39SAndroid Build Coastguard Worker #   define U_CDECL_END
87*0e209d39SAndroid Build Coastguard Worker #endif
88*0e209d39SAndroid Build Coastguard Worker 
89*0e209d39SAndroid Build Coastguard Worker #ifndef U_ATTRIBUTE_DEPRECATED
90*0e209d39SAndroid Build Coastguard Worker /**
91*0e209d39SAndroid Build Coastguard Worker  * \def U_ATTRIBUTE_DEPRECATED
92*0e209d39SAndroid Build Coastguard Worker  *  This is used for GCC specific attributes
93*0e209d39SAndroid Build Coastguard Worker  * @internal
94*0e209d39SAndroid Build Coastguard Worker  */
95*0e209d39SAndroid Build Coastguard Worker #if U_GCC_MAJOR_MINOR >= 302
96*0e209d39SAndroid Build Coastguard Worker #    define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
97*0e209d39SAndroid Build Coastguard Worker /**
98*0e209d39SAndroid Build Coastguard Worker  * \def U_ATTRIBUTE_DEPRECATED
99*0e209d39SAndroid Build Coastguard Worker  * This is used for Visual C++ specific attributes
100*0e209d39SAndroid Build Coastguard Worker  * @internal
101*0e209d39SAndroid Build Coastguard Worker  */
102*0e209d39SAndroid Build Coastguard Worker #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
103*0e209d39SAndroid Build Coastguard Worker #    define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
104*0e209d39SAndroid Build Coastguard Worker #else
105*0e209d39SAndroid Build Coastguard Worker #    define U_ATTRIBUTE_DEPRECATED
106*0e209d39SAndroid Build Coastguard Worker #endif
107*0e209d39SAndroid Build Coastguard Worker #endif
108*0e209d39SAndroid Build Coastguard Worker 
109*0e209d39SAndroid Build Coastguard Worker /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
110*0e209d39SAndroid Build Coastguard Worker #define U_CAPI U_CFUNC U_EXPORT
111*0e209d39SAndroid Build Coastguard Worker /** Obsolete/same as U_CAPI; was used to declare a function as a stable public ICU C API*/
112*0e209d39SAndroid Build Coastguard Worker #define U_STABLE U_CAPI
113*0e209d39SAndroid Build Coastguard Worker /** Obsolete/same as U_CAPI; was used to declare a function as a draft public ICU C API  */
114*0e209d39SAndroid Build Coastguard Worker #define U_DRAFT  U_CAPI
115*0e209d39SAndroid Build Coastguard Worker /** This is used to declare a function as a deprecated public ICU C API  */
116*0e209d39SAndroid Build Coastguard Worker #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
117*0e209d39SAndroid Build Coastguard Worker /** Obsolete/same as U_CAPI; was used to declare a function as an obsolete public ICU C API  */
118*0e209d39SAndroid Build Coastguard Worker #define U_OBSOLETE U_CAPI
119*0e209d39SAndroid Build Coastguard Worker /** Obsolete/same as U_CAPI; was used to declare a function as an internal ICU C API  */
120*0e209d39SAndroid Build Coastguard Worker #define U_INTERNAL U_CAPI
121*0e209d39SAndroid Build Coastguard Worker 
122*0e209d39SAndroid Build Coastguard Worker // Before ICU 65, function-like, multi-statement ICU macros were just defined as
123*0e209d39SAndroid Build Coastguard Worker // series of statements wrapped in { } blocks and the caller could choose to
124*0e209d39SAndroid Build Coastguard Worker // either treat them as if they were actual functions and end the invocation
125*0e209d39SAndroid Build Coastguard Worker // with a trailing ; creating an empty statement after the block or else omit
126*0e209d39SAndroid Build Coastguard Worker // this trailing ; using the knowledge that the macro would expand to { }.
127*0e209d39SAndroid Build Coastguard Worker //
128*0e209d39SAndroid Build Coastguard Worker // But doing so doesn't work well with macros that look like functions and
129*0e209d39SAndroid Build Coastguard Worker // compiler warnings about empty statements (ICU-20601) and ICU 65 therefore
130*0e209d39SAndroid Build Coastguard Worker // switches to the standard solution of wrapping such macros in do { } while.
131*0e209d39SAndroid Build Coastguard Worker //
132*0e209d39SAndroid Build Coastguard Worker // This will however break existing code that depends on being able to invoke
133*0e209d39SAndroid Build Coastguard Worker // these macros without a trailing ; so to be able to remain compatible with
134*0e209d39SAndroid Build Coastguard Worker // such code the wrapper is itself defined as macros so that it's possible to
135*0e209d39SAndroid Build Coastguard Worker // build ICU 65 and later with the old macro behaviour, like this:
136*0e209d39SAndroid Build Coastguard Worker //
137*0e209d39SAndroid Build Coastguard Worker // export CPPFLAGS='-DUPRV_BLOCK_MACRO_BEGIN="" -DUPRV_BLOCK_MACRO_END=""'
138*0e209d39SAndroid Build Coastguard Worker // runConfigureICU ...
139*0e209d39SAndroid Build Coastguard Worker //
140*0e209d39SAndroid Build Coastguard Worker 
141*0e209d39SAndroid Build Coastguard Worker /**
142*0e209d39SAndroid Build Coastguard Worker  * \def UPRV_BLOCK_MACRO_BEGIN
143*0e209d39SAndroid Build Coastguard Worker  * Defined as the "do" keyword by default.
144*0e209d39SAndroid Build Coastguard Worker  * @internal
145*0e209d39SAndroid Build Coastguard Worker  */
146*0e209d39SAndroid Build Coastguard Worker #ifndef UPRV_BLOCK_MACRO_BEGIN
147*0e209d39SAndroid Build Coastguard Worker #define UPRV_BLOCK_MACRO_BEGIN do
148*0e209d39SAndroid Build Coastguard Worker #endif
149*0e209d39SAndroid Build Coastguard Worker 
150*0e209d39SAndroid Build Coastguard Worker /**
151*0e209d39SAndroid Build Coastguard Worker  * \def UPRV_BLOCK_MACRO_END
152*0e209d39SAndroid Build Coastguard Worker  * Defined as "while (false)" by default.
153*0e209d39SAndroid Build Coastguard Worker  * @internal
154*0e209d39SAndroid Build Coastguard Worker  */
155*0e209d39SAndroid Build Coastguard Worker #ifndef UPRV_BLOCK_MACRO_END
156*0e209d39SAndroid Build Coastguard Worker #define UPRV_BLOCK_MACRO_END while (false)
157*0e209d39SAndroid Build Coastguard Worker #endif
158*0e209d39SAndroid Build Coastguard Worker 
159*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
160*0e209d39SAndroid Build Coastguard Worker /* limits for int32_t etc., like in POSIX inttypes.h                        */
161*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
162*0e209d39SAndroid Build Coastguard Worker 
163*0e209d39SAndroid Build Coastguard Worker #ifndef INT8_MIN
164*0e209d39SAndroid Build Coastguard Worker /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
165*0e209d39SAndroid Build Coastguard Worker #   define INT8_MIN        ((int8_t)(-128))
166*0e209d39SAndroid Build Coastguard Worker #endif
167*0e209d39SAndroid Build Coastguard Worker #ifndef INT16_MIN
168*0e209d39SAndroid Build Coastguard Worker /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
169*0e209d39SAndroid Build Coastguard Worker #   define INT16_MIN       ((int16_t)(-32767-1))
170*0e209d39SAndroid Build Coastguard Worker #endif
171*0e209d39SAndroid Build Coastguard Worker #ifndef INT32_MIN
172*0e209d39SAndroid Build Coastguard Worker /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
173*0e209d39SAndroid Build Coastguard Worker #   define INT32_MIN       ((int32_t)(-2147483647-1))
174*0e209d39SAndroid Build Coastguard Worker #endif
175*0e209d39SAndroid Build Coastguard Worker 
176*0e209d39SAndroid Build Coastguard Worker #ifndef INT8_MAX
177*0e209d39SAndroid Build Coastguard Worker /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
178*0e209d39SAndroid Build Coastguard Worker #   define INT8_MAX        ((int8_t)(127))
179*0e209d39SAndroid Build Coastguard Worker #endif
180*0e209d39SAndroid Build Coastguard Worker #ifndef INT16_MAX
181*0e209d39SAndroid Build Coastguard Worker /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
182*0e209d39SAndroid Build Coastguard Worker #   define INT16_MAX       ((int16_t)(32767))
183*0e209d39SAndroid Build Coastguard Worker #endif
184*0e209d39SAndroid Build Coastguard Worker #ifndef INT32_MAX
185*0e209d39SAndroid Build Coastguard Worker /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
186*0e209d39SAndroid Build Coastguard Worker #   define INT32_MAX       ((int32_t)(2147483647))
187*0e209d39SAndroid Build Coastguard Worker #endif
188*0e209d39SAndroid Build Coastguard Worker 
189*0e209d39SAndroid Build Coastguard Worker #ifndef UINT8_MAX
190*0e209d39SAndroid Build Coastguard Worker /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
191*0e209d39SAndroid Build Coastguard Worker #   define UINT8_MAX       ((uint8_t)(255U))
192*0e209d39SAndroid Build Coastguard Worker #endif
193*0e209d39SAndroid Build Coastguard Worker #ifndef UINT16_MAX
194*0e209d39SAndroid Build Coastguard Worker /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
195*0e209d39SAndroid Build Coastguard Worker #   define UINT16_MAX      ((uint16_t)(65535U))
196*0e209d39SAndroid Build Coastguard Worker #endif
197*0e209d39SAndroid Build Coastguard Worker #ifndef UINT32_MAX
198*0e209d39SAndroid Build Coastguard Worker /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
199*0e209d39SAndroid Build Coastguard Worker #   define UINT32_MAX      ((uint32_t)(4294967295U))
200*0e209d39SAndroid Build Coastguard Worker #endif
201*0e209d39SAndroid Build Coastguard Worker 
202*0e209d39SAndroid Build Coastguard Worker #if defined(U_INT64_T_UNAVAILABLE)
203*0e209d39SAndroid Build Coastguard Worker # error int64_t is required for decimal format and rule-based number format.
204*0e209d39SAndroid Build Coastguard Worker #else
205*0e209d39SAndroid Build Coastguard Worker # ifndef INT64_C
206*0e209d39SAndroid Build Coastguard Worker /**
207*0e209d39SAndroid Build Coastguard Worker  * Provides a platform independent way to specify a signed 64-bit integer constant.
208*0e209d39SAndroid Build Coastguard Worker  * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
209*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
210*0e209d39SAndroid Build Coastguard Worker  */
211*0e209d39SAndroid Build Coastguard Worker #   define INT64_C(c) c ## LL
212*0e209d39SAndroid Build Coastguard Worker # endif
213*0e209d39SAndroid Build Coastguard Worker # ifndef UINT64_C
214*0e209d39SAndroid Build Coastguard Worker /**
215*0e209d39SAndroid Build Coastguard Worker  * Provides a platform independent way to specify an unsigned 64-bit integer constant.
216*0e209d39SAndroid Build Coastguard Worker  * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
217*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
218*0e209d39SAndroid Build Coastguard Worker  */
219*0e209d39SAndroid Build Coastguard Worker #   define UINT64_C(c) c ## ULL
220*0e209d39SAndroid Build Coastguard Worker # endif
221*0e209d39SAndroid Build Coastguard Worker # ifndef U_INT64_MIN
222*0e209d39SAndroid Build Coastguard Worker /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
223*0e209d39SAndroid Build Coastguard Worker #     define U_INT64_MIN       ((int64_t)(INT64_C(-9223372036854775807)-1))
224*0e209d39SAndroid Build Coastguard Worker # endif
225*0e209d39SAndroid Build Coastguard Worker # ifndef U_INT64_MAX
226*0e209d39SAndroid Build Coastguard Worker /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
227*0e209d39SAndroid Build Coastguard Worker #     define U_INT64_MAX       ((int64_t)(INT64_C(9223372036854775807)))
228*0e209d39SAndroid Build Coastguard Worker # endif
229*0e209d39SAndroid Build Coastguard Worker # ifndef U_UINT64_MAX
230*0e209d39SAndroid Build Coastguard Worker /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
231*0e209d39SAndroid Build Coastguard Worker #     define U_UINT64_MAX      ((uint64_t)(UINT64_C(18446744073709551615)))
232*0e209d39SAndroid Build Coastguard Worker # endif
233*0e209d39SAndroid Build Coastguard Worker #endif
234*0e209d39SAndroid Build Coastguard Worker 
235*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
236*0e209d39SAndroid Build Coastguard Worker /* Boolean data type                                                        */
237*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
238*0e209d39SAndroid Build Coastguard Worker 
239*0e209d39SAndroid Build Coastguard Worker /**
240*0e209d39SAndroid Build Coastguard Worker  * The ICU boolean type, a signed-byte integer.
241*0e209d39SAndroid Build Coastguard Worker  * ICU-specific for historical reasons: The C and C++ standards used to not define type bool.
242*0e209d39SAndroid Build Coastguard Worker  * Also provides a fixed type definition, as opposed to
243*0e209d39SAndroid Build Coastguard Worker  * type bool whose details (e.g., sizeof) may vary by compiler and between C and C++.
244*0e209d39SAndroid Build Coastguard Worker  *
245*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.0
246*0e209d39SAndroid Build Coastguard Worker  */
247*0e209d39SAndroid Build Coastguard Worker typedef int8_t UBool;
248*0e209d39SAndroid Build Coastguard Worker 
249*0e209d39SAndroid Build Coastguard Worker /**
250*0e209d39SAndroid Build Coastguard Worker  * \def U_DEFINE_FALSE_AND_TRUE
251*0e209d39SAndroid Build Coastguard Worker  * Normally turns off defining macros FALSE=0 & TRUE=1 in public ICU headers.
252*0e209d39SAndroid Build Coastguard Worker  * These obsolete macros sometimes break compilation of other code that
253*0e209d39SAndroid Build Coastguard Worker  * defines enum constants or similar with these names.
254*0e209d39SAndroid Build Coastguard Worker  * C++ has long defined bool/false/true.
255*0e209d39SAndroid Build Coastguard Worker  * C99 also added definitions for these, although as macros; see stdbool.h.
256*0e209d39SAndroid Build Coastguard Worker  *
257*0e209d39SAndroid Build Coastguard Worker  * You may transitionally define U_DEFINE_FALSE_AND_TRUE=1 if you need time to migrate code.
258*0e209d39SAndroid Build Coastguard Worker  *
259*0e209d39SAndroid Build Coastguard Worker  * @internal ICU 68
260*0e209d39SAndroid Build Coastguard Worker  */
261*0e209d39SAndroid Build Coastguard Worker #ifdef U_DEFINE_FALSE_AND_TRUE
262*0e209d39SAndroid Build Coastguard Worker     // Use the predefined value.
263*0e209d39SAndroid Build Coastguard Worker #else
264*0e209d39SAndroid Build Coastguard Worker     // Default to avoiding collision with non-macro definitions of FALSE & TRUE.
265*0e209d39SAndroid Build Coastguard Worker #   define U_DEFINE_FALSE_AND_TRUE 0
266*0e209d39SAndroid Build Coastguard Worker #endif
267*0e209d39SAndroid Build Coastguard Worker 
268*0e209d39SAndroid Build Coastguard Worker #if U_DEFINE_FALSE_AND_TRUE || defined(U_IN_DOXYGEN)
269*0e209d39SAndroid Build Coastguard Worker #ifndef TRUE
270*0e209d39SAndroid Build Coastguard Worker /**
271*0e209d39SAndroid Build Coastguard Worker  * The TRUE value of a UBool.
272*0e209d39SAndroid Build Coastguard Worker  *
273*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 68 Use standard "true" instead.
274*0e209d39SAndroid Build Coastguard Worker  */
275*0e209d39SAndroid Build Coastguard Worker #   define TRUE  1
276*0e209d39SAndroid Build Coastguard Worker #endif
277*0e209d39SAndroid Build Coastguard Worker #ifndef FALSE
278*0e209d39SAndroid Build Coastguard Worker /**
279*0e209d39SAndroid Build Coastguard Worker  * The FALSE value of a UBool.
280*0e209d39SAndroid Build Coastguard Worker  *
281*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 68 Use standard "false" instead.
282*0e209d39SAndroid Build Coastguard Worker  */
283*0e209d39SAndroid Build Coastguard Worker #   define FALSE 0
284*0e209d39SAndroid Build Coastguard Worker #endif
285*0e209d39SAndroid Build Coastguard Worker #endif  // U_DEFINE_FALSE_AND_TRUE
286*0e209d39SAndroid Build Coastguard Worker 
287*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
288*0e209d39SAndroid Build Coastguard Worker /* Unicode data types                                                       */
289*0e209d39SAndroid Build Coastguard Worker /*==========================================================================*/
290*0e209d39SAndroid Build Coastguard Worker 
291*0e209d39SAndroid Build Coastguard Worker /* wchar_t-related definitions -------------------------------------------- */
292*0e209d39SAndroid Build Coastguard Worker 
293*0e209d39SAndroid Build Coastguard Worker /*
294*0e209d39SAndroid Build Coastguard Worker  * \def U_WCHAR_IS_UTF16
295*0e209d39SAndroid Build Coastguard Worker  * Defined if wchar_t uses UTF-16.
296*0e209d39SAndroid Build Coastguard Worker  *
297*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.0
298*0e209d39SAndroid Build Coastguard Worker  */
299*0e209d39SAndroid Build Coastguard Worker /*
300*0e209d39SAndroid Build Coastguard Worker  * \def U_WCHAR_IS_UTF32
301*0e209d39SAndroid Build Coastguard Worker  * Defined if wchar_t uses UTF-32.
302*0e209d39SAndroid Build Coastguard Worker  *
303*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.0
304*0e209d39SAndroid Build Coastguard Worker  */
305*0e209d39SAndroid Build Coastguard Worker #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
306*0e209d39SAndroid Build Coastguard Worker #   ifdef __STDC_ISO_10646__
307*0e209d39SAndroid Build Coastguard Worker #       if (U_SIZEOF_WCHAR_T==2)
308*0e209d39SAndroid Build Coastguard Worker #           define U_WCHAR_IS_UTF16
309*0e209d39SAndroid Build Coastguard Worker #       elif (U_SIZEOF_WCHAR_T==4)
310*0e209d39SAndroid Build Coastguard Worker #           define  U_WCHAR_IS_UTF32
311*0e209d39SAndroid Build Coastguard Worker #       endif
312*0e209d39SAndroid Build Coastguard Worker #   elif defined __UCS2__
313*0e209d39SAndroid Build Coastguard Worker #       if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
314*0e209d39SAndroid Build Coastguard Worker #           define U_WCHAR_IS_UTF16
315*0e209d39SAndroid Build Coastguard Worker #       endif
316*0e209d39SAndroid Build Coastguard Worker #   elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
317*0e209d39SAndroid Build Coastguard Worker #       if (U_SIZEOF_WCHAR_T==4)
318*0e209d39SAndroid Build Coastguard Worker #           define U_WCHAR_IS_UTF32
319*0e209d39SAndroid Build Coastguard Worker #       endif
320*0e209d39SAndroid Build Coastguard Worker #   elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
321*0e209d39SAndroid Build Coastguard Worker #       define U_WCHAR_IS_UTF32
322*0e209d39SAndroid Build Coastguard Worker #   elif U_PLATFORM_HAS_WIN32_API
323*0e209d39SAndroid Build Coastguard Worker #       define U_WCHAR_IS_UTF16
324*0e209d39SAndroid Build Coastguard Worker #   endif
325*0e209d39SAndroid Build Coastguard Worker #endif
326*0e209d39SAndroid Build Coastguard Worker 
327*0e209d39SAndroid Build Coastguard Worker /* UChar and UChar32 definitions -------------------------------------------- */
328*0e209d39SAndroid Build Coastguard Worker 
329*0e209d39SAndroid Build Coastguard Worker /** Number of bytes in a UChar (always 2). @stable ICU 2.0 */
330*0e209d39SAndroid Build Coastguard Worker #define U_SIZEOF_UCHAR 2
331*0e209d39SAndroid Build Coastguard Worker 
332*0e209d39SAndroid Build Coastguard Worker /**
333*0e209d39SAndroid Build Coastguard Worker  * \def U_CHAR16_IS_TYPEDEF
334*0e209d39SAndroid Build Coastguard Worker  * If 1, then char16_t is a typedef and not a real type (yet)
335*0e209d39SAndroid Build Coastguard Worker  * @internal
336*0e209d39SAndroid Build Coastguard Worker  */
337*0e209d39SAndroid Build Coastguard Worker #if defined(_MSC_VER) && (_MSC_VER < 1900)
338*0e209d39SAndroid Build Coastguard Worker // Versions of Visual Studio/MSVC below 2015 do not support char16_t as a real type,
339*0e209d39SAndroid Build Coastguard Worker // and instead use a typedef.  https://msdn.microsoft.com/library/bb531344.aspx
340*0e209d39SAndroid Build Coastguard Worker # define U_CHAR16_IS_TYPEDEF 1
341*0e209d39SAndroid Build Coastguard Worker #else
342*0e209d39SAndroid Build Coastguard Worker # define U_CHAR16_IS_TYPEDEF 0
343*0e209d39SAndroid Build Coastguard Worker #endif
344*0e209d39SAndroid Build Coastguard Worker 
345*0e209d39SAndroid Build Coastguard Worker 
346*0e209d39SAndroid Build Coastguard Worker /**
347*0e209d39SAndroid Build Coastguard Worker  * \var UChar
348*0e209d39SAndroid Build Coastguard Worker  *
349*0e209d39SAndroid Build Coastguard Worker  * The base type for UTF-16 code units and pointers.
350*0e209d39SAndroid Build Coastguard Worker  * Unsigned 16-bit integer.
351*0e209d39SAndroid Build Coastguard Worker  * Starting with ICU 59, C++ API uses char16_t directly, while C API continues to use UChar.
352*0e209d39SAndroid Build Coastguard Worker  *
353*0e209d39SAndroid Build Coastguard Worker  * UChar is configurable by defining the macro UCHAR_TYPE
354*0e209d39SAndroid Build Coastguard Worker  * on the preprocessor or compiler command line:
355*0e209d39SAndroid Build Coastguard Worker  * -DUCHAR_TYPE=uint16_t or -DUCHAR_TYPE=wchar_t (if U_SIZEOF_WCHAR_T==2) etc.
356*0e209d39SAndroid Build Coastguard Worker  * (The UCHAR_TYPE can also be \#defined earlier in this file, for outside the ICU library code.)
357*0e209d39SAndroid Build Coastguard Worker  * This is for transitional use from application code that uses uint16_t or wchar_t for UTF-16.
358*0e209d39SAndroid Build Coastguard Worker  *
359*0e209d39SAndroid Build Coastguard Worker  * The default is UChar=char16_t.
360*0e209d39SAndroid Build Coastguard Worker  *
361*0e209d39SAndroid Build Coastguard Worker  * C++11 defines char16_t as bit-compatible with uint16_t, but as a distinct type.
362*0e209d39SAndroid Build Coastguard Worker  *
363*0e209d39SAndroid Build Coastguard Worker  * In C, char16_t is a simple typedef of uint_least16_t.
364*0e209d39SAndroid Build Coastguard Worker  * ICU requires uint_least16_t=uint16_t for data memory mapping.
365*0e209d39SAndroid Build Coastguard Worker  * On macOS, char16_t is not available because the uchar.h standard header is missing.
366*0e209d39SAndroid Build Coastguard Worker  *
367*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 4.4
368*0e209d39SAndroid Build Coastguard Worker  */
369*0e209d39SAndroid Build Coastguard Worker 
370*0e209d39SAndroid Build Coastguard Worker #if 1
371*0e209d39SAndroid Build Coastguard Worker     // #if 1 is normal. UChar defaults to char16_t in C++.
372*0e209d39SAndroid Build Coastguard Worker     // For configuration testing of UChar=uint16_t temporarily change this to #if 0.
373*0e209d39SAndroid Build Coastguard Worker #else
374*0e209d39SAndroid Build Coastguard Worker #   define UCHAR_TYPE uint16_t
375*0e209d39SAndroid Build Coastguard Worker #endif
376*0e209d39SAndroid Build Coastguard Worker 
377*0e209d39SAndroid Build Coastguard Worker #if defined(U_ALL_IMPLEMENTATION) || !defined(UCHAR_TYPE)
378*0e209d39SAndroid Build Coastguard Worker     typedef char16_t UChar;
379*0e209d39SAndroid Build Coastguard Worker #else
380*0e209d39SAndroid Build Coastguard Worker     typedef UCHAR_TYPE UChar;
381*0e209d39SAndroid Build Coastguard Worker #endif
382*0e209d39SAndroid Build Coastguard Worker 
383*0e209d39SAndroid Build Coastguard Worker /**
384*0e209d39SAndroid Build Coastguard Worker  * \var OldUChar
385*0e209d39SAndroid Build Coastguard Worker  * Default ICU 58 definition of UChar.
386*0e209d39SAndroid Build Coastguard Worker  * A base type for UTF-16 code units and pointers.
387*0e209d39SAndroid Build Coastguard Worker  * Unsigned 16-bit integer.
388*0e209d39SAndroid Build Coastguard Worker  *
389*0e209d39SAndroid Build Coastguard Worker  * Define OldUChar to be wchar_t if that is 16 bits wide.
390*0e209d39SAndroid Build Coastguard Worker  * If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
391*0e209d39SAndroid Build Coastguard Worker  *
392*0e209d39SAndroid Build Coastguard Worker  * This makes the definition of OldUChar platform-dependent
393*0e209d39SAndroid Build Coastguard Worker  * but allows direct string type compatibility with platforms with
394*0e209d39SAndroid Build Coastguard Worker  * 16-bit wchar_t types.
395*0e209d39SAndroid Build Coastguard Worker  *
396*0e209d39SAndroid Build Coastguard Worker  * This is how UChar was defined in ICU 58, for transition convenience.
397*0e209d39SAndroid Build Coastguard Worker  * Exception: ICU 58 UChar was defined to UCHAR_TYPE if that macro was defined.
398*0e209d39SAndroid Build Coastguard Worker  * The current UChar responds to UCHAR_TYPE but OldUChar does not.
399*0e209d39SAndroid Build Coastguard Worker  *
400*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 59
401*0e209d39SAndroid Build Coastguard Worker  */
402*0e209d39SAndroid Build Coastguard Worker #if U_SIZEOF_WCHAR_T==2
403*0e209d39SAndroid Build Coastguard Worker     typedef wchar_t OldUChar;
404*0e209d39SAndroid Build Coastguard Worker #elif defined(__CHAR16_TYPE__)
405*0e209d39SAndroid Build Coastguard Worker     typedef __CHAR16_TYPE__ OldUChar;
406*0e209d39SAndroid Build Coastguard Worker #else
407*0e209d39SAndroid Build Coastguard Worker     typedef uint16_t OldUChar;
408*0e209d39SAndroid Build Coastguard Worker #endif
409*0e209d39SAndroid Build Coastguard Worker 
410*0e209d39SAndroid Build Coastguard Worker /**
411*0e209d39SAndroid Build Coastguard Worker  * Define UChar32 as a type for single Unicode code points.
412*0e209d39SAndroid Build Coastguard Worker  * UChar32 is a signed 32-bit integer (same as int32_t).
413*0e209d39SAndroid Build Coastguard Worker  *
414*0e209d39SAndroid Build Coastguard Worker  * The Unicode code point range is 0..0x10ffff.
415*0e209d39SAndroid Build Coastguard Worker  * All other values (negative or >=0x110000) are illegal as Unicode code points.
416*0e209d39SAndroid Build Coastguard Worker  * They may be used as sentinel values to indicate "done", "error"
417*0e209d39SAndroid Build Coastguard Worker  * or similar non-code point conditions.
418*0e209d39SAndroid Build Coastguard Worker  *
419*0e209d39SAndroid Build Coastguard Worker  * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
420*0e209d39SAndroid Build Coastguard Worker  * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
421*0e209d39SAndroid Build Coastguard Worker  * or else to be uint32_t.
422*0e209d39SAndroid Build Coastguard Worker  * That is, the definition of UChar32 was platform-dependent.
423*0e209d39SAndroid Build Coastguard Worker  *
424*0e209d39SAndroid Build Coastguard Worker  * @see U_SENTINEL
425*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
426*0e209d39SAndroid Build Coastguard Worker  */
427*0e209d39SAndroid Build Coastguard Worker typedef int32_t UChar32;
428*0e209d39SAndroid Build Coastguard Worker 
429*0e209d39SAndroid Build Coastguard Worker /**
430*0e209d39SAndroid Build Coastguard Worker  * This value is intended for sentinel values for APIs that
431*0e209d39SAndroid Build Coastguard Worker  * (take or) return single code points (UChar32).
432*0e209d39SAndroid Build Coastguard Worker  * It is outside of the Unicode code point range 0..0x10ffff.
433*0e209d39SAndroid Build Coastguard Worker  *
434*0e209d39SAndroid Build Coastguard Worker  * For example, a "done" or "error" value in a new API
435*0e209d39SAndroid Build Coastguard Worker  * could be indicated with U_SENTINEL.
436*0e209d39SAndroid Build Coastguard Worker  *
437*0e209d39SAndroid Build Coastguard Worker  * ICU APIs designed before ICU 2.4 usually define service-specific "done"
438*0e209d39SAndroid Build Coastguard Worker  * values, mostly 0xffff.
439*0e209d39SAndroid Build Coastguard Worker  * Those may need to be distinguished from
440*0e209d39SAndroid Build Coastguard Worker  * actual U+ffff text contents by calling functions like
441*0e209d39SAndroid Build Coastguard Worker  * CharacterIterator::hasNext() or UnicodeString::length().
442*0e209d39SAndroid Build Coastguard Worker  *
443*0e209d39SAndroid Build Coastguard Worker  * @return -1
444*0e209d39SAndroid Build Coastguard Worker  * @see UChar32
445*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.4
446*0e209d39SAndroid Build Coastguard Worker  */
447*0e209d39SAndroid Build Coastguard Worker #define U_SENTINEL (-1)
448*0e209d39SAndroid Build Coastguard Worker 
449*0e209d39SAndroid Build Coastguard Worker #include "unicode/urename.h"
450*0e209d39SAndroid Build Coastguard Worker 
451*0e209d39SAndroid Build Coastguard Worker #endif
452