17777dab0Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
27777dab0Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
37777dab0Sopenharmony_ci/*
47777dab0Sopenharmony_ci******************************************************************************
57777dab0Sopenharmony_ci*
67777dab0Sopenharmony_ci*   Copyright (C) 1999-2015, International Business Machines
77777dab0Sopenharmony_ci*   Corporation and others.  All Rights Reserved.
87777dab0Sopenharmony_ci*
97777dab0Sopenharmony_ci******************************************************************************
107777dab0Sopenharmony_ci*   file name:  umachine.h
117777dab0Sopenharmony_ci*   encoding:   UTF-8
127777dab0Sopenharmony_ci*   tab size:   8 (not used)
137777dab0Sopenharmony_ci*   indentation:4
147777dab0Sopenharmony_ci*
157777dab0Sopenharmony_ci*   created on: 1999sep13
167777dab0Sopenharmony_ci*   created by: Markus W. Scherer
177777dab0Sopenharmony_ci*
187777dab0Sopenharmony_ci*   This file defines basic types and constants for ICU to be
197777dab0Sopenharmony_ci*   platform-independent. umachine.h and utf.h are included into
207777dab0Sopenharmony_ci*   utypes.h to provide all the general definitions for ICU.
217777dab0Sopenharmony_ci*   All of these definitions used to be in utypes.h before
227777dab0Sopenharmony_ci*   the UTF-handling macros made this unmaintainable.
237777dab0Sopenharmony_ci*/
247777dab0Sopenharmony_ci
257777dab0Sopenharmony_ci#ifndef __UMACHINE_H__
267777dab0Sopenharmony_ci#define __UMACHINE_H__
277777dab0Sopenharmony_ci/**
287777dab0Sopenharmony_ci * \file
297777dab0Sopenharmony_ci * \brief Basic types and constants for UTF
307777dab0Sopenharmony_ci *
317777dab0Sopenharmony_ci * <h2> Basic types and constants for UTF </h2>
327777dab0Sopenharmony_ci *   This file defines basic types and constants for utf.h to be
337777dab0Sopenharmony_ci *   platform-independent. umachine.h and utf.h are included into
347777dab0Sopenharmony_ci *   utypes.h to provide all the general definitions for ICU.
357777dab0Sopenharmony_ci *   All of these definitions used to be in utypes.h before
367777dab0Sopenharmony_ci *   the UTF-handling macros made this unmaintainable.
377777dab0Sopenharmony_ci *
387777dab0Sopenharmony_ci */
397777dab0Sopenharmony_ci/*==========================================================================*/
407777dab0Sopenharmony_ci/* Include platform-dependent definitions                                   */
417777dab0Sopenharmony_ci/* which are contained in the platform-specific file platform.h             */
427777dab0Sopenharmony_ci/*==========================================================================*/
437777dab0Sopenharmony_ci
447777dab0Sopenharmony_ci#include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
457777dab0Sopenharmony_ci
467777dab0Sopenharmony_ci/*
477777dab0Sopenharmony_ci * ANSI C headers:
487777dab0Sopenharmony_ci * stddef.h defines wchar_t
497777dab0Sopenharmony_ci */
507777dab0Sopenharmony_ci#include <stdbool.h>
517777dab0Sopenharmony_ci#include <stddef.h>
527777dab0Sopenharmony_ci
537777dab0Sopenharmony_ci/*==========================================================================*/
547777dab0Sopenharmony_ci/* For C wrappers, we use the symbol U_CAPI.                                */
557777dab0Sopenharmony_ci/* This works properly if the includer is C or C++.                         */
567777dab0Sopenharmony_ci/* Functions are declared   U_CAPI return-type U_EXPORT2 function-name()... */
577777dab0Sopenharmony_ci/*==========================================================================*/
587777dab0Sopenharmony_ci
597777dab0Sopenharmony_ci/**
607777dab0Sopenharmony_ci * \def U_CFUNC
617777dab0Sopenharmony_ci * This is used in a declaration of a library private ICU C function.
627777dab0Sopenharmony_ci * @stable ICU 2.4
637777dab0Sopenharmony_ci */
647777dab0Sopenharmony_ci
657777dab0Sopenharmony_ci/**
667777dab0Sopenharmony_ci * \def U_CDECL_BEGIN
677777dab0Sopenharmony_ci * This is used to begin a declaration of a library private ICU C API.
687777dab0Sopenharmony_ci * @stable ICU 2.4
697777dab0Sopenharmony_ci */
707777dab0Sopenharmony_ci
717777dab0Sopenharmony_ci/**
727777dab0Sopenharmony_ci * \def U_CDECL_END
737777dab0Sopenharmony_ci * This is used to end a declaration of a library private ICU C API
747777dab0Sopenharmony_ci * @stable ICU 2.4
757777dab0Sopenharmony_ci */
767777dab0Sopenharmony_ci
777777dab0Sopenharmony_ci#ifdef __cplusplus
787777dab0Sopenharmony_ci#   define U_CFUNC extern "C"
797777dab0Sopenharmony_ci#   define U_CDECL_BEGIN extern "C" {
807777dab0Sopenharmony_ci#   define U_CDECL_END   }
817777dab0Sopenharmony_ci#else
827777dab0Sopenharmony_ci#   define U_CFUNC extern
837777dab0Sopenharmony_ci#   define U_CDECL_BEGIN
847777dab0Sopenharmony_ci#   define U_CDECL_END
857777dab0Sopenharmony_ci#endif
867777dab0Sopenharmony_ci
877777dab0Sopenharmony_ci#ifndef U_ATTRIBUTE_DEPRECATED
887777dab0Sopenharmony_ci/**
897777dab0Sopenharmony_ci * \def U_ATTRIBUTE_DEPRECATED
907777dab0Sopenharmony_ci *  This is used for GCC specific attributes
917777dab0Sopenharmony_ci * @internal
927777dab0Sopenharmony_ci */
937777dab0Sopenharmony_ci#if U_GCC_MAJOR_MINOR >= 302
947777dab0Sopenharmony_ci#    define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
957777dab0Sopenharmony_ci/**
967777dab0Sopenharmony_ci * \def U_ATTRIBUTE_DEPRECATED
977777dab0Sopenharmony_ci * This is used for Visual C++ specific attributes
987777dab0Sopenharmony_ci * @internal
997777dab0Sopenharmony_ci */
1007777dab0Sopenharmony_ci#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
1017777dab0Sopenharmony_ci#    define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
1027777dab0Sopenharmony_ci#else
1037777dab0Sopenharmony_ci#    define U_ATTRIBUTE_DEPRECATED
1047777dab0Sopenharmony_ci#endif
1057777dab0Sopenharmony_ci#endif
1067777dab0Sopenharmony_ci
1077777dab0Sopenharmony_ci/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
1087777dab0Sopenharmony_ci#define U_CAPI U_CFUNC U_EXPORT
1097777dab0Sopenharmony_ci/** Obsolete/same as U_CAPI; was used to declare a function as a stable public ICU C API*/
1107777dab0Sopenharmony_ci#define U_STABLE U_CAPI
1117777dab0Sopenharmony_ci/** Obsolete/same as U_CAPI; was used to declare a function as a draft public ICU C API  */
1127777dab0Sopenharmony_ci#define U_DRAFT  U_CAPI
1137777dab0Sopenharmony_ci/** This is used to declare a function as a deprecated public ICU C API  */
1147777dab0Sopenharmony_ci#define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
1157777dab0Sopenharmony_ci/** Obsolete/same as U_CAPI; was used to declare a function as an obsolete public ICU C API  */
1167777dab0Sopenharmony_ci#define U_OBSOLETE U_CAPI
1177777dab0Sopenharmony_ci/** Obsolete/same as U_CAPI; was used to declare a function as an internal ICU C API  */
1187777dab0Sopenharmony_ci#define U_INTERNAL U_CAPI
1197777dab0Sopenharmony_ci
1207777dab0Sopenharmony_ci/**
1217777dab0Sopenharmony_ci * \def U_OVERRIDE
1227777dab0Sopenharmony_ci * Defined to the C++11 "override" keyword if available.
1237777dab0Sopenharmony_ci * Denotes a class or member which is an override of the base class.
1247777dab0Sopenharmony_ci * May result in an error if it applied to something not an override.
1257777dab0Sopenharmony_ci * @internal
1267777dab0Sopenharmony_ci */
1277777dab0Sopenharmony_ci#ifndef U_OVERRIDE
1287777dab0Sopenharmony_ci#define U_OVERRIDE override
1297777dab0Sopenharmony_ci#endif
1307777dab0Sopenharmony_ci
1317777dab0Sopenharmony_ci/**
1327777dab0Sopenharmony_ci * \def U_FINAL
1337777dab0Sopenharmony_ci * Defined to the C++11 "final" keyword if available.
1347777dab0Sopenharmony_ci * Denotes a class or member which may not be overridden in subclasses.
1357777dab0Sopenharmony_ci * May result in an error if subclasses attempt to override.
1367777dab0Sopenharmony_ci * @internal
1377777dab0Sopenharmony_ci */
1387777dab0Sopenharmony_ci#if !defined(U_FINAL) || defined(U_IN_DOXYGEN)
1397777dab0Sopenharmony_ci#define U_FINAL final
1407777dab0Sopenharmony_ci#endif
1417777dab0Sopenharmony_ci
1427777dab0Sopenharmony_ci// Before ICU 65, function-like, multi-statement ICU macros were just defined as
1437777dab0Sopenharmony_ci// series of statements wrapped in { } blocks and the caller could choose to
1447777dab0Sopenharmony_ci// either treat them as if they were actual functions and end the invocation
1457777dab0Sopenharmony_ci// with a trailing ; creating an empty statement after the block or else omit
1467777dab0Sopenharmony_ci// this trailing ; using the knowledge that the macro would expand to { }.
1477777dab0Sopenharmony_ci//
1487777dab0Sopenharmony_ci// But doing so doesn't work well with macros that look like functions and
1497777dab0Sopenharmony_ci// compiler warnings about empty statements (ICU-20601) and ICU 65 therefore
1507777dab0Sopenharmony_ci// switches to the standard solution of wrapping such macros in do { } while.
1517777dab0Sopenharmony_ci//
1527777dab0Sopenharmony_ci// This will however break existing code that depends on being able to invoke
1537777dab0Sopenharmony_ci// these macros without a trailing ; so to be able to remain compatible with
1547777dab0Sopenharmony_ci// such code the wrapper is itself defined as macros so that it's possible to
1557777dab0Sopenharmony_ci// build ICU 65 and later with the old macro behaviour, like this:
1567777dab0Sopenharmony_ci//
1577777dab0Sopenharmony_ci// export CPPFLAGS='-DUPRV_BLOCK_MACRO_BEGIN="" -DUPRV_BLOCK_MACRO_END=""'
1587777dab0Sopenharmony_ci// runConfigureICU ...
1597777dab0Sopenharmony_ci//
1607777dab0Sopenharmony_ci
1617777dab0Sopenharmony_ci/**
1627777dab0Sopenharmony_ci * \def UPRV_BLOCK_MACRO_BEGIN
1637777dab0Sopenharmony_ci * Defined as the "do" keyword by default.
1647777dab0Sopenharmony_ci * @internal
1657777dab0Sopenharmony_ci */
1667777dab0Sopenharmony_ci#ifndef UPRV_BLOCK_MACRO_BEGIN
1677777dab0Sopenharmony_ci#define UPRV_BLOCK_MACRO_BEGIN do
1687777dab0Sopenharmony_ci#endif
1697777dab0Sopenharmony_ci
1707777dab0Sopenharmony_ci/**
1717777dab0Sopenharmony_ci * \def UPRV_BLOCK_MACRO_END
1727777dab0Sopenharmony_ci * Defined as "while (false)" by default.
1737777dab0Sopenharmony_ci * @internal
1747777dab0Sopenharmony_ci */
1757777dab0Sopenharmony_ci#ifndef UPRV_BLOCK_MACRO_END
1767777dab0Sopenharmony_ci#define UPRV_BLOCK_MACRO_END while (false)
1777777dab0Sopenharmony_ci#endif
1787777dab0Sopenharmony_ci
1797777dab0Sopenharmony_ci/*==========================================================================*/
1807777dab0Sopenharmony_ci/* limits for int32_t etc., like in POSIX inttypes.h                        */
1817777dab0Sopenharmony_ci/*==========================================================================*/
1827777dab0Sopenharmony_ci
1837777dab0Sopenharmony_ci#ifndef INT8_MIN
1847777dab0Sopenharmony_ci/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
1857777dab0Sopenharmony_ci#   define INT8_MIN        ((int8_t)(-128))
1867777dab0Sopenharmony_ci#endif
1877777dab0Sopenharmony_ci#ifndef INT16_MIN
1887777dab0Sopenharmony_ci/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
1897777dab0Sopenharmony_ci#   define INT16_MIN       ((int16_t)(-32767-1))
1907777dab0Sopenharmony_ci#endif
1917777dab0Sopenharmony_ci#ifndef INT32_MIN
1927777dab0Sopenharmony_ci/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
1937777dab0Sopenharmony_ci#   define INT32_MIN       ((int32_t)(-2147483647-1))
1947777dab0Sopenharmony_ci#endif
1957777dab0Sopenharmony_ci
1967777dab0Sopenharmony_ci#ifndef INT8_MAX
1977777dab0Sopenharmony_ci/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
1987777dab0Sopenharmony_ci#   define INT8_MAX        ((int8_t)(127))
1997777dab0Sopenharmony_ci#endif
2007777dab0Sopenharmony_ci#ifndef INT16_MAX
2017777dab0Sopenharmony_ci/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
2027777dab0Sopenharmony_ci#   define INT16_MAX       ((int16_t)(32767))
2037777dab0Sopenharmony_ci#endif
2047777dab0Sopenharmony_ci#ifndef INT32_MAX
2057777dab0Sopenharmony_ci/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
2067777dab0Sopenharmony_ci#   define INT32_MAX       ((int32_t)(2147483647))
2077777dab0Sopenharmony_ci#endif
2087777dab0Sopenharmony_ci
2097777dab0Sopenharmony_ci#ifndef UINT8_MAX
2107777dab0Sopenharmony_ci/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
2117777dab0Sopenharmony_ci#   define UINT8_MAX       ((uint8_t)(255U))
2127777dab0Sopenharmony_ci#endif
2137777dab0Sopenharmony_ci#ifndef UINT16_MAX
2147777dab0Sopenharmony_ci/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
2157777dab0Sopenharmony_ci#   define UINT16_MAX      ((uint16_t)(65535U))
2167777dab0Sopenharmony_ci#endif
2177777dab0Sopenharmony_ci#ifndef UINT32_MAX
2187777dab0Sopenharmony_ci/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
2197777dab0Sopenharmony_ci#   define UINT32_MAX      ((uint32_t)(4294967295U))
2207777dab0Sopenharmony_ci#endif
2217777dab0Sopenharmony_ci
2227777dab0Sopenharmony_ci#if defined(U_INT64_T_UNAVAILABLE)
2237777dab0Sopenharmony_ci# error int64_t is required for decimal format and rule-based number format.
2247777dab0Sopenharmony_ci#else
2257777dab0Sopenharmony_ci# ifndef INT64_C
2267777dab0Sopenharmony_ci/**
2277777dab0Sopenharmony_ci * Provides a platform independent way to specify a signed 64-bit integer constant.
2287777dab0Sopenharmony_ci * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
2297777dab0Sopenharmony_ci * @stable ICU 2.8
2307777dab0Sopenharmony_ci */
2317777dab0Sopenharmony_ci#   define INT64_C(c) c ## LL
2327777dab0Sopenharmony_ci# endif
2337777dab0Sopenharmony_ci# ifndef UINT64_C
2347777dab0Sopenharmony_ci/**
2357777dab0Sopenharmony_ci * Provides a platform independent way to specify an unsigned 64-bit integer constant.
2367777dab0Sopenharmony_ci * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
2377777dab0Sopenharmony_ci * @stable ICU 2.8
2387777dab0Sopenharmony_ci */
2397777dab0Sopenharmony_ci#   define UINT64_C(c) c ## ULL
2407777dab0Sopenharmony_ci# endif
2417777dab0Sopenharmony_ci# ifndef U_INT64_MIN
2427777dab0Sopenharmony_ci/** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
2437777dab0Sopenharmony_ci#     define U_INT64_MIN       ((int64_t)(INT64_C(-9223372036854775807)-1))
2447777dab0Sopenharmony_ci# endif
2457777dab0Sopenharmony_ci# ifndef U_INT64_MAX
2467777dab0Sopenharmony_ci/** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
2477777dab0Sopenharmony_ci#     define U_INT64_MAX       ((int64_t)(INT64_C(9223372036854775807)))
2487777dab0Sopenharmony_ci# endif
2497777dab0Sopenharmony_ci# ifndef U_UINT64_MAX
2507777dab0Sopenharmony_ci/** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
2517777dab0Sopenharmony_ci#     define U_UINT64_MAX      ((uint64_t)(UINT64_C(18446744073709551615)))
2527777dab0Sopenharmony_ci# endif
2537777dab0Sopenharmony_ci#endif
2547777dab0Sopenharmony_ci
2557777dab0Sopenharmony_ci/*==========================================================================*/
2567777dab0Sopenharmony_ci/* Boolean data type                                                        */
2577777dab0Sopenharmony_ci/*==========================================================================*/
2587777dab0Sopenharmony_ci
2597777dab0Sopenharmony_ci/**
2607777dab0Sopenharmony_ci * The ICU boolean type, a signed-byte integer.
2617777dab0Sopenharmony_ci * ICU-specific for historical reasons: The C and C++ standards used to not define type bool.
2627777dab0Sopenharmony_ci * Also provides a fixed type definition, as opposed to
2637777dab0Sopenharmony_ci * type bool whose details (e.g., sizeof) may vary by compiler and between C and C++.
2647777dab0Sopenharmony_ci *
2657777dab0Sopenharmony_ci * @stable ICU 2.0
2667777dab0Sopenharmony_ci */
2677777dab0Sopenharmony_citypedef int8_t UBool;
2687777dab0Sopenharmony_ci
2697777dab0Sopenharmony_ci/**
2707777dab0Sopenharmony_ci * \def U_DEFINE_FALSE_AND_TRUE
2717777dab0Sopenharmony_ci * Normally turns off defining macros FALSE=0 & TRUE=1 in public ICU headers.
2727777dab0Sopenharmony_ci * These obsolete macros sometimes break compilation of other code that
2737777dab0Sopenharmony_ci * defines enum constants or similar with these names.
2747777dab0Sopenharmony_ci * C++ has long defined bool/false/true.
2757777dab0Sopenharmony_ci * C99 also added definitions for these, although as macros; see stdbool.h.
2767777dab0Sopenharmony_ci *
2777777dab0Sopenharmony_ci * You may transitionally define U_DEFINE_FALSE_AND_TRUE=1 if you need time to migrate code.
2787777dab0Sopenharmony_ci *
2797777dab0Sopenharmony_ci * @internal ICU 68
2807777dab0Sopenharmony_ci */
2817777dab0Sopenharmony_ci#ifdef U_DEFINE_FALSE_AND_TRUE
2827777dab0Sopenharmony_ci    // Use the predefined value.
2837777dab0Sopenharmony_ci#elif defined(U_COMBINED_IMPLEMENTATION) || \
2847777dab0Sopenharmony_ci        defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || \
2857777dab0Sopenharmony_ci        defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || \
2867777dab0Sopenharmony_ci        defined(U_TOOLUTIL_IMPLEMENTATION)
2877777dab0Sopenharmony_ci    // Inside ICU: Keep FALSE & TRUE available.
2887777dab0Sopenharmony_ci#   define U_DEFINE_FALSE_AND_TRUE 1
2897777dab0Sopenharmony_ci#else
2907777dab0Sopenharmony_ci    // Outside ICU: Avoid collision with non-macro definitions of FALSE & TRUE.
2917777dab0Sopenharmony_ci#   define U_DEFINE_FALSE_AND_TRUE 1
2927777dab0Sopenharmony_ci#endif
2937777dab0Sopenharmony_ci
2947777dab0Sopenharmony_ci#if U_DEFINE_FALSE_AND_TRUE || defined(U_IN_DOXYGEN)
2957777dab0Sopenharmony_ci#ifndef TRUE
2967777dab0Sopenharmony_ci/**
2977777dab0Sopenharmony_ci * The TRUE value of a UBool.
2987777dab0Sopenharmony_ci *
2997777dab0Sopenharmony_ci * @deprecated ICU 68 Use standard "true" instead.
3007777dab0Sopenharmony_ci */
3017777dab0Sopenharmony_ci#   define TRUE  1
3027777dab0Sopenharmony_ci#endif
3037777dab0Sopenharmony_ci#ifndef FALSE
3047777dab0Sopenharmony_ci/**
3057777dab0Sopenharmony_ci * The FALSE value of a UBool.
3067777dab0Sopenharmony_ci *
3077777dab0Sopenharmony_ci * @deprecated ICU 68 Use standard "false" instead.
3087777dab0Sopenharmony_ci */
3097777dab0Sopenharmony_ci#   define FALSE 0
3107777dab0Sopenharmony_ci#endif
3117777dab0Sopenharmony_ci#endif  // U_DEFINE_FALSE_AND_TRUE
3127777dab0Sopenharmony_ci
3137777dab0Sopenharmony_ci/*==========================================================================*/
3147777dab0Sopenharmony_ci/* Unicode data types                                                       */
3157777dab0Sopenharmony_ci/*==========================================================================*/
3167777dab0Sopenharmony_ci
3177777dab0Sopenharmony_ci/* wchar_t-related definitions -------------------------------------------- */
3187777dab0Sopenharmony_ci
3197777dab0Sopenharmony_ci/*
3207777dab0Sopenharmony_ci * \def U_WCHAR_IS_UTF16
3217777dab0Sopenharmony_ci * Defined if wchar_t uses UTF-16.
3227777dab0Sopenharmony_ci *
3237777dab0Sopenharmony_ci * @stable ICU 2.0
3247777dab0Sopenharmony_ci */
3257777dab0Sopenharmony_ci/*
3267777dab0Sopenharmony_ci * \def U_WCHAR_IS_UTF32
3277777dab0Sopenharmony_ci * Defined if wchar_t uses UTF-32.
3287777dab0Sopenharmony_ci *
3297777dab0Sopenharmony_ci * @stable ICU 2.0
3307777dab0Sopenharmony_ci */
3317777dab0Sopenharmony_ci#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
3327777dab0Sopenharmony_ci#   ifdef __STDC_ISO_10646__
3337777dab0Sopenharmony_ci#       if (U_SIZEOF_WCHAR_T==2)
3347777dab0Sopenharmony_ci#           define U_WCHAR_IS_UTF16
3357777dab0Sopenharmony_ci#       elif (U_SIZEOF_WCHAR_T==4)
3367777dab0Sopenharmony_ci#           define  U_WCHAR_IS_UTF32
3377777dab0Sopenharmony_ci#       endif
3387777dab0Sopenharmony_ci#   elif defined __UCS2__
3397777dab0Sopenharmony_ci#       if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
3407777dab0Sopenharmony_ci#           define U_WCHAR_IS_UTF16
3417777dab0Sopenharmony_ci#       endif
3427777dab0Sopenharmony_ci#   elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
3437777dab0Sopenharmony_ci#       if (U_SIZEOF_WCHAR_T==4)
3447777dab0Sopenharmony_ci#           define U_WCHAR_IS_UTF32
3457777dab0Sopenharmony_ci#       endif
3467777dab0Sopenharmony_ci#   elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
3477777dab0Sopenharmony_ci#       define U_WCHAR_IS_UTF32
3487777dab0Sopenharmony_ci#   elif U_PLATFORM_HAS_WIN32_API
3497777dab0Sopenharmony_ci#       define U_WCHAR_IS_UTF16
3507777dab0Sopenharmony_ci#   endif
3517777dab0Sopenharmony_ci#endif
3527777dab0Sopenharmony_ci
3537777dab0Sopenharmony_ci/* UChar and UChar32 definitions -------------------------------------------- */
3547777dab0Sopenharmony_ci
3557777dab0Sopenharmony_ci/** Number of bytes in a UChar. @stable ICU 2.0 */
3567777dab0Sopenharmony_ci#define U_SIZEOF_UCHAR 2
3577777dab0Sopenharmony_ci
3587777dab0Sopenharmony_ci/**
3597777dab0Sopenharmony_ci * \def U_CHAR16_IS_TYPEDEF
3607777dab0Sopenharmony_ci * If 1, then char16_t is a typedef and not a real type (yet)
3617777dab0Sopenharmony_ci * @internal
3627777dab0Sopenharmony_ci */
3637777dab0Sopenharmony_ci#if (U_PLATFORM == U_PF_AIX) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
3647777dab0Sopenharmony_ci// for AIX, uchar.h needs to be included
3657777dab0Sopenharmony_ci# include <uchar.h>
3667777dab0Sopenharmony_ci# define U_CHAR16_IS_TYPEDEF 1
3677777dab0Sopenharmony_ci#elif defined(_MSC_VER) && (_MSC_VER < 1900)
3687777dab0Sopenharmony_ci// Versions of Visual Studio/MSVC below 2015 do not support char16_t as a real type,
3697777dab0Sopenharmony_ci// and instead use a typedef.  https://msdn.microsoft.com/library/bb531344.aspx
3707777dab0Sopenharmony_ci# define U_CHAR16_IS_TYPEDEF 1
3717777dab0Sopenharmony_ci#else
3727777dab0Sopenharmony_ci# define U_CHAR16_IS_TYPEDEF 0
3737777dab0Sopenharmony_ci#endif
3747777dab0Sopenharmony_ci/**
3757777dab0Sopenharmony_ci * \var UChar
3767777dab0Sopenharmony_ci *
3777777dab0Sopenharmony_ci * The base type for UTF-16 code units and pointers.
3787777dab0Sopenharmony_ci * Unsigned 16-bit integer.
3797777dab0Sopenharmony_ci * Starting with ICU 59, C++ API uses char16_t directly, while C API continues to use UChar.
3807777dab0Sopenharmony_ci *
3817777dab0Sopenharmony_ci * UChar is configurable by defining the macro UCHAR_TYPE
3827777dab0Sopenharmony_ci * on the preprocessor or compiler command line:
3837777dab0Sopenharmony_ci * -DUCHAR_TYPE=uint16_t or -DUCHAR_TYPE=wchar_t (if U_SIZEOF_WCHAR_T==2) etc.
3847777dab0Sopenharmony_ci * (The UCHAR_TYPE can also be \#defined earlier in this file, for outside the ICU library code.)
3857777dab0Sopenharmony_ci * This is for transitional use from application code that uses uint16_t or wchar_t for UTF-16.
3867777dab0Sopenharmony_ci *
3877777dab0Sopenharmony_ci * The default is UChar=char16_t.
3887777dab0Sopenharmony_ci *
3897777dab0Sopenharmony_ci * C++11 defines char16_t as bit-compatible with uint16_t, but as a distinct type.
3907777dab0Sopenharmony_ci *
3917777dab0Sopenharmony_ci * In C, char16_t is a simple typedef of uint_least16_t.
3927777dab0Sopenharmony_ci * ICU requires uint_least16_t=uint16_t for data memory mapping.
3937777dab0Sopenharmony_ci * On macOS, char16_t is not available because the uchar.h standard header is missing.
3947777dab0Sopenharmony_ci *
3957777dab0Sopenharmony_ci * @stable ICU 4.4
3967777dab0Sopenharmony_ci */
3977777dab0Sopenharmony_ci
3987777dab0Sopenharmony_ci#if 1
3997777dab0Sopenharmony_ci    // #if 1 is normal. UChar defaults to char16_t in C++.
4007777dab0Sopenharmony_ci    // For configuration testing of UChar=uint16_t temporarily change this to #if 0.
4017777dab0Sopenharmony_ci    // The intltest Makefile #defines UCHAR_TYPE=char16_t,
4027777dab0Sopenharmony_ci    // so we only #define it to uint16_t if it is undefined so far.
4037777dab0Sopenharmony_ci#elif !defined(UCHAR_TYPE)
4047777dab0Sopenharmony_ci#   define UCHAR_TYPE uint16_t
4057777dab0Sopenharmony_ci#endif
4067777dab0Sopenharmony_ci
4077777dab0Sopenharmony_ci#if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \
4087777dab0Sopenharmony_ci        defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
4097777dab0Sopenharmony_ci    // Inside the ICU library code, never configurable.
4107777dab0Sopenharmony_ci    typedef char16_t UChar;
4117777dab0Sopenharmony_ci#elif defined(UCHAR_TYPE)
4127777dab0Sopenharmony_ci    typedef UCHAR_TYPE UChar;
4137777dab0Sopenharmony_ci#elif (U_CPLUSPLUS_VERSION >= 11)
4147777dab0Sopenharmony_ci    typedef char16_t UChar;
4157777dab0Sopenharmony_ci#else
4167777dab0Sopenharmony_ci    typedef uint16_t UChar;
4177777dab0Sopenharmony_ci#endif
4187777dab0Sopenharmony_ci
4197777dab0Sopenharmony_ci/**
4207777dab0Sopenharmony_ci * \var OldUChar
4217777dab0Sopenharmony_ci * Default ICU 58 definition of UChar.
4227777dab0Sopenharmony_ci * A base type for UTF-16 code units and pointers.
4237777dab0Sopenharmony_ci * Unsigned 16-bit integer.
4247777dab0Sopenharmony_ci *
4257777dab0Sopenharmony_ci * Define OldUChar to be wchar_t if that is 16 bits wide.
4267777dab0Sopenharmony_ci * If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
4277777dab0Sopenharmony_ci *
4287777dab0Sopenharmony_ci * This makes the definition of OldUChar platform-dependent
4297777dab0Sopenharmony_ci * but allows direct string type compatibility with platforms with
4307777dab0Sopenharmony_ci * 16-bit wchar_t types.
4317777dab0Sopenharmony_ci *
4327777dab0Sopenharmony_ci * This is how UChar was defined in ICU 58, for transition convenience.
4337777dab0Sopenharmony_ci * Exception: ICU 58 UChar was defined to UCHAR_TYPE if that macro was defined.
4347777dab0Sopenharmony_ci * The current UChar responds to UCHAR_TYPE but OldUChar does not.
4357777dab0Sopenharmony_ci *
4367777dab0Sopenharmony_ci * @stable ICU 59
4377777dab0Sopenharmony_ci */
4387777dab0Sopenharmony_ci#if U_SIZEOF_WCHAR_T==2
4397777dab0Sopenharmony_ci    typedef wchar_t OldUChar;
4407777dab0Sopenharmony_ci#elif defined(__CHAR16_TYPE__)
4417777dab0Sopenharmony_ci    typedef __CHAR16_TYPE__ OldUChar;
4427777dab0Sopenharmony_ci#else
4437777dab0Sopenharmony_ci    typedef uint16_t OldUChar;
4447777dab0Sopenharmony_ci#endif
4457777dab0Sopenharmony_ci
4467777dab0Sopenharmony_ci/**
4477777dab0Sopenharmony_ci * Define UChar32 as a type for single Unicode code points.
4487777dab0Sopenharmony_ci * UChar32 is a signed 32-bit integer (same as int32_t).
4497777dab0Sopenharmony_ci *
4507777dab0Sopenharmony_ci * The Unicode code point range is 0..0x10ffff.
4517777dab0Sopenharmony_ci * All other values (negative or >=0x110000) are illegal as Unicode code points.
4527777dab0Sopenharmony_ci * They may be used as sentinel values to indicate "done", "error"
4537777dab0Sopenharmony_ci * or similar non-code point conditions.
4547777dab0Sopenharmony_ci *
4557777dab0Sopenharmony_ci * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
4567777dab0Sopenharmony_ci * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
4577777dab0Sopenharmony_ci * or else to be uint32_t.
4587777dab0Sopenharmony_ci * That is, the definition of UChar32 was platform-dependent.
4597777dab0Sopenharmony_ci *
4607777dab0Sopenharmony_ci * @see U_SENTINEL
4617777dab0Sopenharmony_ci * @stable ICU 2.4
4627777dab0Sopenharmony_ci */
4637777dab0Sopenharmony_citypedef int32_t UChar32;
4647777dab0Sopenharmony_ci
4657777dab0Sopenharmony_ci/**
4667777dab0Sopenharmony_ci * This value is intended for sentinel values for APIs that
4677777dab0Sopenharmony_ci * (take or) return single code points (UChar32).
4687777dab0Sopenharmony_ci * It is outside of the Unicode code point range 0..0x10ffff.
4697777dab0Sopenharmony_ci *
4707777dab0Sopenharmony_ci * For example, a "done" or "error" value in a new API
4717777dab0Sopenharmony_ci * could be indicated with U_SENTINEL.
4727777dab0Sopenharmony_ci *
4737777dab0Sopenharmony_ci * ICU APIs designed before ICU 2.4 usually define service-specific "done"
4747777dab0Sopenharmony_ci * values, mostly 0xffff.
4757777dab0Sopenharmony_ci * Those may need to be distinguished from
4767777dab0Sopenharmony_ci * actual U+ffff text contents by calling functions like
4777777dab0Sopenharmony_ci * CharacterIterator::hasNext() or UnicodeString::length().
4787777dab0Sopenharmony_ci *
4797777dab0Sopenharmony_ci * @return -1
4807777dab0Sopenharmony_ci * @see UChar32
4817777dab0Sopenharmony_ci * @stable ICU 2.4
4827777dab0Sopenharmony_ci */
4837777dab0Sopenharmony_ci#define U_SENTINEL (-1)
4847777dab0Sopenharmony_ci
4857777dab0Sopenharmony_ci#endif
486