1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*******************************************************************************
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius*   Copyright (C) 1999-2011, International Business Machines
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*******************************************************************************
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   file name:  utf.h
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   encoding:   US-ASCII
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   tab size:   8 (not used)
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   indentation:4
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   created on: 1999sep09
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   created by: Markus W. Scherer
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C API: Code point macros
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This file defines macros for checking whether a code point is
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a surrogate or a non-character etc.
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The UChar and UChar32 data types for Unicode code units and code points
2583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * are defined in umachine.h because they can be machine-dependent.
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
2783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * If U_NO_DEFAULT_INCLUDE_UTF_HEADERS is 0 then utf.h is included by utypes.h
2883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * and itself includes utf8.h and utf16.h after some
2983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * common definitions.
3083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * If U_NO_DEFAULT_INCLUDE_UTF_HEADERS is 1 then each of these headers must be
3183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * included explicitly if their definitions are used.
3283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius *
3383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * utf8.h and utf16.h define macros for efficiently getting code points
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in and out of UTF-8/16 strings.
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * utf16.h macros have "U16_" prefixes.
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * utf8.h defines similar macros with "U8_" prefixes for UTF-8 string handling.
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
3883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * ICU mostly processes 16-bit Unicode strings.
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Most of the time, such strings are well-formed UTF-16.
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Single, unpaired surrogates must be handled as well, and are treated in ICU
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * like regular code points where possible.
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (Pairs of surrogate code points are indistinguishable from supplementary
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * code points encoded as pairs of supplementary code units.)
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In fact, almost all Unicode code points in normal text (>99%)
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are on the BMP (<=U+ffff) and even <=U+d7ff.
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ICU functions handle supplementary code points (U+10000..U+10ffff)
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * but are optimized for the much more frequently occurring BMP code points.
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
5083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * umachine.h defines UChar to be an unsigned 16-bit integer.
5183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * Where available, UChar is defined to be a char16_t
5283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * or a wchar_t (if that is an unsigned 16-bit type), otherwise uint16_t.
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Unicode code point (Unicode scalar value, 0..0x10ffff).
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the definition of UChar. For details see the documentation for UChar32 itself.
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
5983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * utf.h defines a small number of C macros for single Unicode code points.
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * These are simple checks for surrogates and non-characters.
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For actual Unicode character properties see uchar.h.
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * By default, string operations must be done with error checking in case
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a string is not well-formed UTF-16.
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The macros will detect if a surrogate code unit is unpaired
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (lead unit without trail unit or vice versa) and just return the unit itself
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * as the code point.
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The regular "safe" macros require that the initial, passed-in string index
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is within bounds. They only check the index when they read more than one
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * code unit. This is usually done with code similar to the following loop:
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>while(i<length) {
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   U16_NEXT(s, i, length, c);
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   // use c
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * }</pre>
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * When it is safe to assume that text is well-formed UTF-16
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (does not contain single, unpaired surrogates), then one can use
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * U16_..._UNSAFE macros.
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * These do not check for proper code unit sequences or truncated text and may
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * yield wrong results or even cause a crash if they are used with "malformed"
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * text.
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In practice, U16_..._UNSAFE macros will produce slightly less code but
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should not be faster because the processing is only different when a
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * surrogate code unit is detected, which will be rare.
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Similarly for UTF-8, there are "safe" macros without a suffix,
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and U8_..._UNSAFE versions.
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The performance differences are much larger here because UTF-8 provides so
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * many opportunities for malformed sequences.
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The unsafe UTF-8 macros are entirely implemented inside the macro definitions
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and are fast, while the safe UTF-8 macros call functions for all but the
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * trivial (ASCII) cases.
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (ICU 3.6 optimizes U8_NEXT() and U8_APPEND() to handle most other common
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters inline as well.)
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Unlike with UTF-16, malformed sequences cannot be expressed with distinct
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * code point values (0..U+10ffff). They are indicated with negative values instead.
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For more information see the ICU User Guide Strings chapter
10183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * (http://userguide.icu-project.org/strings).
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>Usage:</em>
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ICU coding guidelines for if() statements should be followed when using these macros.
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Compound statements (curly braces {}) must be used  for if-else-while...
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * bodies and all macro statements should be terminated with semicolon.
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef __UTF_H__
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define __UTF_H__
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
11483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#include "unicode/umachine.h"
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* include the utfXX.h after the following definitions */
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* single-code point definitions -------------------------------------------- */
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is this code point a Unicode noncharacter?
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_UNICODE_NONCHAR(c) \
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ((c)>=0xfdd0 && \
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     (uint32_t)(c)<=0x10ffff)
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is c a Unicode code point value (0..U+10ffff)
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that can be assigned a character?
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Code points that are not characters include:
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * - single surrogate code points (U+d800..U+dfff, 2048 code points)
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * - the highest Unicode code point value is U+10ffff
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This means that all code points below U+d800 are character code points,
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and that boundary is tested first for performance.
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_UNICODE_CHAR(c) \
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ((uint32_t)(c)<0xd800 || \
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ((uint32_t)(c)>0xdfff && \
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         (uint32_t)(c)<=0x10ffff && \
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         !U_IS_UNICODE_NONCHAR(c)))
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is this code point a BMP code point (U+0000..U+ffff)?
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_BMP(c) ((uint32_t)(c)<=0xffff)
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is this code point a supplementary code point (U+10000..U+10ffff)?
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff)
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is this code point a lead surrogate (U+d800..U+dbff)?
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is this code point a trail surrogate (U+dc00..U+dfff)?
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Is this code point a surrogate (U+d800..U+dfff)?
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800)
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is it a lead surrogate?
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param c 32-bit code point
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE or FALSE
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define U_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
20285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho/**
20385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
20485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * is it a trail surrogate?
20585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param c 32-bit code point
20685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @return TRUE or FALSE
20727f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 4.2
20885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho */
20985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define U_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)
21085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* include the utfXX.h ------------------------------------------------------ */
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS
21483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utf8.h"
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utf16.h"
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* utf_old.h contains deprecated, pre-ICU 2.4 definitions */
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utf_old.h"
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
22183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif  /* !U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
22283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius
22383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif  /* __UTF_H__ */
224