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