xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/utf_old.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) 2002-2012, 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:  utf_old.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: 2002sep21
16*0e209d39SAndroid Build Coastguard Worker *   created by: Markus W. Scherer
17*0e209d39SAndroid Build Coastguard Worker */
18*0e209d39SAndroid Build Coastguard Worker 
19*0e209d39SAndroid Build Coastguard Worker /**
20*0e209d39SAndroid Build Coastguard Worker  * \file
21*0e209d39SAndroid Build Coastguard Worker  * \brief C API: Deprecated macros for Unicode string handling
22*0e209d39SAndroid Build Coastguard Worker  *
23*0e209d39SAndroid Build Coastguard Worker  * The macros in utf_old.h are all deprecated and their use discouraged.
24*0e209d39SAndroid Build Coastguard Worker  * Some of the design principles behind the set of UTF macros
25*0e209d39SAndroid Build Coastguard Worker  * have changed or proved impractical.
26*0e209d39SAndroid Build Coastguard Worker  * Almost all of the old "UTF macros" are at least renamed.
27*0e209d39SAndroid Build Coastguard Worker  * If you are looking for a new equivalent to an old macro, please see the
28*0e209d39SAndroid Build Coastguard Worker  * comment at the old one.
29*0e209d39SAndroid Build Coastguard Worker  *
30*0e209d39SAndroid Build Coastguard Worker  * Brief summary of reasons for deprecation:
31*0e209d39SAndroid Build Coastguard Worker  * - Switch on UTF_SIZE (selection of UTF-8/16/32 default string processing)
32*0e209d39SAndroid Build Coastguard Worker  *   was impractical.
33*0e209d39SAndroid Build Coastguard Worker  * - Switch on UTF_SAFE etc. (selection of unsafe/safe/strict default string processing)
34*0e209d39SAndroid Build Coastguard Worker  *   was of little use and impractical.
35*0e209d39SAndroid Build Coastguard Worker  * - Whole classes of macros became obsolete outside of the UTF_SIZE/UTF_SAFE
36*0e209d39SAndroid Build Coastguard Worker  *   selection framework: UTF32_ macros (all trivial)
37*0e209d39SAndroid Build Coastguard Worker  *   and UTF_ default and intermediate macros (all aliases).
38*0e209d39SAndroid Build Coastguard Worker  * - The selection framework also caused many macro aliases.
39*0e209d39SAndroid Build Coastguard Worker  * - Change in Unicode standard: "irregular" sequences (3.0) became illegal (3.2).
40*0e209d39SAndroid Build Coastguard Worker  * - Change of language in Unicode standard:
41*0e209d39SAndroid Build Coastguard Worker  *   Growing distinction between internal x-bit Unicode strings and external UTF-x
42*0e209d39SAndroid Build Coastguard Worker  *   forms, with the former more lenient.
43*0e209d39SAndroid Build Coastguard Worker  *   Suggests renaming of UTF16_ macros to U16_.
44*0e209d39SAndroid Build Coastguard Worker  * - The prefix "UTF_" without a width number confused some users.
45*0e209d39SAndroid Build Coastguard Worker  * - "Safe" append macros needed the addition of an error indicator output.
46*0e209d39SAndroid Build Coastguard Worker  * - "Safe" UTF-8 macros used legitimate (if rarely used) code point values
47*0e209d39SAndroid Build Coastguard Worker  *   to indicate error conditions.
48*0e209d39SAndroid Build Coastguard Worker  * - The use of the "_CHAR" infix for code point operations confused some users.
49*0e209d39SAndroid Build Coastguard Worker  *
50*0e209d39SAndroid Build Coastguard Worker  * More details:
51*0e209d39SAndroid Build Coastguard Worker  *
52*0e209d39SAndroid Build Coastguard Worker  * Until ICU 2.2, utf.h theoretically allowed to choose among UTF-8/16/32
53*0e209d39SAndroid Build Coastguard Worker  * for string processing, and among unsafe/safe/strict default macros for that.
54*0e209d39SAndroid Build Coastguard Worker  *
55*0e209d39SAndroid Build Coastguard Worker  * It proved nearly impossible to write non-trivial, high-performance code
56*0e209d39SAndroid Build Coastguard Worker  * that is UTF-generic.
57*0e209d39SAndroid Build Coastguard Worker  * Unsafe default macros would be dangerous for default string processing,
58*0e209d39SAndroid Build Coastguard Worker  * and the main reason for the "strict" versions disappeared:
59*0e209d39SAndroid Build Coastguard Worker  * Between Unicode 3.0 and 3.2 all "irregular" UTF-8 sequences became illegal.
60*0e209d39SAndroid Build Coastguard Worker  * The only other conditions that "strict" checked for were non-characters,
61*0e209d39SAndroid Build Coastguard Worker  * which are valid during processing. Only during text input/output should they
62*0e209d39SAndroid Build Coastguard Worker  * be checked, and at that time other well-formedness checks may be
63*0e209d39SAndroid Build Coastguard Worker  * necessary or useful as well.
64*0e209d39SAndroid Build Coastguard Worker  * This can still be done by using U16_NEXT and U_IS_UNICODE_NONCHAR
65*0e209d39SAndroid Build Coastguard Worker  * or U_IS_UNICODE_CHAR.
66*0e209d39SAndroid Build Coastguard Worker  *
67*0e209d39SAndroid Build Coastguard Worker  * The old UTF8_..._SAFE macros also used some normal Unicode code points
68*0e209d39SAndroid Build Coastguard Worker  * to indicate malformed sequences.
69*0e209d39SAndroid Build Coastguard Worker  * The new UTF8_ macros without suffix use negative values instead.
70*0e209d39SAndroid Build Coastguard Worker  *
71*0e209d39SAndroid Build Coastguard Worker  * The entire contents of utf32.h was moved here without replacement
72*0e209d39SAndroid Build Coastguard Worker  * because all those macros were trivial and
73*0e209d39SAndroid Build Coastguard Worker  * were meaningful only in the framework of choosing the UTF size.
74*0e209d39SAndroid Build Coastguard Worker  *
75*0e209d39SAndroid Build Coastguard Worker  * See Jitterbug 2150 and its discussion on the ICU mailing list
76*0e209d39SAndroid Build Coastguard Worker  * in September 2002.
77*0e209d39SAndroid Build Coastguard Worker  *
78*0e209d39SAndroid Build Coastguard Worker  * <hr>
79*0e209d39SAndroid Build Coastguard Worker  *
80*0e209d39SAndroid Build Coastguard Worker  * <em>Obsolete part</em> of pre-ICU 2.4 utf.h file documentation:
81*0e209d39SAndroid Build Coastguard Worker  *
82*0e209d39SAndroid Build Coastguard Worker  * <p>The original concept for these files was for ICU to allow
83*0e209d39SAndroid Build Coastguard Worker  * in principle to set which UTF (UTF-8/16/32) is used internally
84*0e209d39SAndroid Build Coastguard Worker  * by defining UTF_SIZE to either 8, 16, or 32. utf.h would then define the UChar type
85*0e209d39SAndroid Build Coastguard Worker  * accordingly. UTF-16 was the default.</p>
86*0e209d39SAndroid Build Coastguard Worker  *
87*0e209d39SAndroid Build Coastguard Worker  * <p>This concept has been abandoned.
88*0e209d39SAndroid Build Coastguard Worker  * A lot of the ICU source code assumes UChar strings are in UTF-16.
89*0e209d39SAndroid Build Coastguard Worker  * This is especially true for low-level code like
90*0e209d39SAndroid Build Coastguard Worker  * conversion, normalization, and collation.
91*0e209d39SAndroid Build Coastguard Worker  * The utf.h header enforces the default of UTF-16.
92*0e209d39SAndroid Build Coastguard Worker  * The UTF-8 and UTF-32 macros remain for now for completeness and backward compatibility.</p>
93*0e209d39SAndroid Build Coastguard Worker  *
94*0e209d39SAndroid Build Coastguard Worker  * <p>Accordingly, utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then
95*0e209d39SAndroid Build Coastguard Worker  * UChar is defined to be exactly wchar_t, otherwise uint16_t.</p>
96*0e209d39SAndroid Build Coastguard Worker  *
97*0e209d39SAndroid Build Coastguard Worker  * <p>UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit
98*0e209d39SAndroid Build Coastguard Worker  * Unicode code point (Unicode scalar value, 0..0x10ffff).
99*0e209d39SAndroid Build Coastguard Worker  * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as
100*0e209d39SAndroid Build Coastguard Worker  * the definition of UChar. For details see the documentation for UChar32 itself.</p>
101*0e209d39SAndroid Build Coastguard Worker  *
102*0e209d39SAndroid Build Coastguard Worker  * <p>utf.h also defines a number of C macros for handling single Unicode code points and
103*0e209d39SAndroid Build Coastguard Worker  * for using UTF Unicode strings. It includes utf8.h, utf16.h, and utf32.h for the actual
104*0e209d39SAndroid Build Coastguard Worker  * implementations of those macros and then aliases one set of them (for UTF-16) for general use.
105*0e209d39SAndroid Build Coastguard Worker  * The UTF-specific macros have the UTF size in the macro name prefixes (UTF16_...), while
106*0e209d39SAndroid Build Coastguard Worker  * the general alias macros always begin with UTF_...</p>
107*0e209d39SAndroid Build Coastguard Worker  *
108*0e209d39SAndroid Build Coastguard Worker  * <p>Many string operations can be done with or without error checking.
109*0e209d39SAndroid Build Coastguard Worker  * Where such a distinction is useful, there are two versions of the macros, "unsafe" and "safe"
110*0e209d39SAndroid Build Coastguard Worker  * ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause
111*0e209d39SAndroid Build Coastguard Worker  * program failures if the strings are not well-formed. The safe macros have an additional, boolean
112*0e209d39SAndroid Build Coastguard Worker  * parameter "strict". If strict is false, then only illegal sequences are detected.
113*0e209d39SAndroid Build Coastguard Worker  * Otherwise, irregular sequences and non-characters are detected as well (like single surrogates).
114*0e209d39SAndroid Build Coastguard Worker  * Safe macros return special error code points for illegal/irregular sequences:
115*0e209d39SAndroid Build Coastguard Worker  * Typically, U+ffff, or values that would result in a code unit sequence of the same length
116*0e209d39SAndroid Build Coastguard Worker  * as the erroneous input sequence.<br>
117*0e209d39SAndroid Build Coastguard Worker  * Note that _UNSAFE macros have fewer parameters: They do not have the strictness parameter, and
118*0e209d39SAndroid Build Coastguard Worker  * they do not have start/length parameters for boundary checking.</p>
119*0e209d39SAndroid Build Coastguard Worker  *
120*0e209d39SAndroid Build Coastguard Worker  * <p>Here, the macros are aliased in two steps:
121*0e209d39SAndroid Build Coastguard Worker  * In the first step, the UTF-specific macros with UTF16_ prefix and _UNSAFE and _SAFE suffixes are
122*0e209d39SAndroid Build Coastguard Worker  * aliased according to the UTF_SIZE to macros with UTF_ prefix and the same suffixes and signatures.
123*0e209d39SAndroid Build Coastguard Worker  * Then, in a second step, the default, general alias macros are set to use either the unsafe or
124*0e209d39SAndroid Build Coastguard Worker  * the safe/not strict (default) or the safe/strict macro;
125*0e209d39SAndroid Build Coastguard Worker  * these general macros do not have a strictness parameter.</p>
126*0e209d39SAndroid Build Coastguard Worker  *
127*0e209d39SAndroid Build Coastguard Worker  * <p>It is possible to change the default choice for the general alias macros to be unsafe, safe/not strict or safe/strict.
128*0e209d39SAndroid Build Coastguard Worker  * The default is safe/not strict. It is not recommended to select the unsafe macros as the basis for
129*0e209d39SAndroid Build Coastguard Worker  * Unicode string handling in ICU! To select this, define UTF_SAFE, UTF_STRICT, or UTF_UNSAFE.</p>
130*0e209d39SAndroid Build Coastguard Worker  *
131*0e209d39SAndroid Build Coastguard Worker  * <p>For general use, one should use the default, general macros with UTF_ prefix and no _SAFE/_UNSAFE suffix.
132*0e209d39SAndroid Build Coastguard Worker  * Only in some cases it may be necessary to control the choice of macro directly and use a less generic alias.
133*0e209d39SAndroid Build Coastguard Worker  * For example, if it can be assumed that a string is well-formed and the index will stay within the bounds,
134*0e209d39SAndroid Build Coastguard Worker  * then the _UNSAFE version may be used.
135*0e209d39SAndroid Build Coastguard Worker  * If a UTF-8 string is to be processed, then the macros with UTF8_ prefixes need to be used.</p>
136*0e209d39SAndroid Build Coastguard Worker  *
137*0e209d39SAndroid Build Coastguard Worker  * <hr>
138*0e209d39SAndroid Build Coastguard Worker  *
139*0e209d39SAndroid Build Coastguard Worker  * Deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead.
140*0e209d39SAndroid Build Coastguard Worker  */
141*0e209d39SAndroid Build Coastguard Worker 
142*0e209d39SAndroid Build Coastguard Worker #ifndef __UTF_OLD_H__
143*0e209d39SAndroid Build Coastguard Worker #define __UTF_OLD_H__
144*0e209d39SAndroid Build Coastguard Worker 
145*0e209d39SAndroid Build Coastguard Worker #include "unicode/utf.h"
146*0e209d39SAndroid Build Coastguard Worker #include "unicode/utf8.h"
147*0e209d39SAndroid Build Coastguard Worker #include "unicode/utf16.h"
148*0e209d39SAndroid Build Coastguard Worker 
149*0e209d39SAndroid Build Coastguard Worker /**
150*0e209d39SAndroid Build Coastguard Worker  * \def U_HIDE_OBSOLETE_UTF_OLD_H
151*0e209d39SAndroid Build Coastguard Worker  *
152*0e209d39SAndroid Build Coastguard Worker  * Hides the obsolete definitions in unicode/utf_old.h.
153*0e209d39SAndroid Build Coastguard Worker  * Recommended to be set to 1 at compile time to make sure
154*0e209d39SAndroid Build Coastguard Worker  * the long-deprecated macros are no longer used.
155*0e209d39SAndroid Build Coastguard Worker  *
156*0e209d39SAndroid Build Coastguard Worker  * For reasons for the deprecation see the utf_old.h file comments.
157*0e209d39SAndroid Build Coastguard Worker  *
158*0e209d39SAndroid Build Coastguard Worker  * @internal
159*0e209d39SAndroid Build Coastguard Worker  */
160*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_OBSOLETE_UTF_OLD_H
161*0e209d39SAndroid Build Coastguard Worker #   define U_HIDE_OBSOLETE_UTF_OLD_H 0
162*0e209d39SAndroid Build Coastguard Worker #endif
163*0e209d39SAndroid Build Coastguard Worker 
164*0e209d39SAndroid Build Coastguard Worker #if !defined(U_HIDE_DEPRECATED_API) && !U_HIDE_OBSOLETE_UTF_OLD_H
165*0e209d39SAndroid Build Coastguard Worker 
166*0e209d39SAndroid Build Coastguard Worker /* Formerly utf.h, part 1 --------------------------------------------------- */
167*0e209d39SAndroid Build Coastguard Worker 
168*0e209d39SAndroid Build Coastguard Worker #ifdef U_USE_UTF_DEPRECATES
169*0e209d39SAndroid Build Coastguard Worker /**
170*0e209d39SAndroid Build Coastguard Worker  * Unicode string and array offset and index type.
171*0e209d39SAndroid Build Coastguard Worker  * ICU always counts Unicode code units (UChars) for
172*0e209d39SAndroid Build Coastguard Worker  * string offsets, indexes, and lengths, not Unicode code points.
173*0e209d39SAndroid Build Coastguard Worker  *
174*0e209d39SAndroid Build Coastguard Worker  * @obsolete ICU 2.6. Use int32_t directly instead since this API will be removed in that release.
175*0e209d39SAndroid Build Coastguard Worker  */
176*0e209d39SAndroid Build Coastguard Worker typedef int32_t UTextOffset;
177*0e209d39SAndroid Build Coastguard Worker #endif
178*0e209d39SAndroid Build Coastguard Worker 
179*0e209d39SAndroid Build Coastguard Worker /** Number of bits in a Unicode string code unit - ICU uses 16-bit Unicode. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
180*0e209d39SAndroid Build Coastguard Worker #define UTF_SIZE 16
181*0e209d39SAndroid Build Coastguard Worker 
182*0e209d39SAndroid Build Coastguard Worker /**
183*0e209d39SAndroid Build Coastguard Worker  * The default choice for general Unicode string macros is to use the ..._SAFE macro implementations
184*0e209d39SAndroid Build Coastguard Worker  * with strict=false.
185*0e209d39SAndroid Build Coastguard Worker  *
186*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
187*0e209d39SAndroid Build Coastguard Worker  */
188*0e209d39SAndroid Build Coastguard Worker #define UTF_SAFE
189*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
190*0e209d39SAndroid Build Coastguard Worker #undef UTF_UNSAFE
191*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
192*0e209d39SAndroid Build Coastguard Worker #undef UTF_STRICT
193*0e209d39SAndroid Build Coastguard Worker 
194*0e209d39SAndroid Build Coastguard Worker /**
195*0e209d39SAndroid Build Coastguard Worker  * UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8,
196*0e209d39SAndroid Build Coastguard Worker  * which need 1 or 2 bytes in UTF-8:
197*0e209d39SAndroid Build Coastguard Worker  * \code
198*0e209d39SAndroid Build Coastguard Worker  * U+0015 = NAK = Negative Acknowledge, C0 control character
199*0e209d39SAndroid Build Coastguard Worker  * U+009f = highest C1 control character
200*0e209d39SAndroid Build Coastguard Worker  * \endcode
201*0e209d39SAndroid Build Coastguard Worker  *
202*0e209d39SAndroid Build Coastguard Worker  * These are used by UTF8_..._SAFE macros so that they can return an error value
203*0e209d39SAndroid Build Coastguard Worker  * that needs the same number of code units (bytes) as were seen by
204*0e209d39SAndroid Build Coastguard Worker  * a macro. They should be tested with UTF_IS_ERROR() or UTF_IS_VALID().
205*0e209d39SAndroid Build Coastguard Worker  *
206*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
207*0e209d39SAndroid Build Coastguard Worker  */
208*0e209d39SAndroid Build Coastguard Worker #define UTF8_ERROR_VALUE_1 0x15
209*0e209d39SAndroid Build Coastguard Worker 
210*0e209d39SAndroid Build Coastguard Worker /**
211*0e209d39SAndroid Build Coastguard Worker  * See documentation on UTF8_ERROR_VALUE_1 for details.
212*0e209d39SAndroid Build Coastguard Worker  *
213*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
214*0e209d39SAndroid Build Coastguard Worker  */
215*0e209d39SAndroid Build Coastguard Worker #define UTF8_ERROR_VALUE_2 0x9f
216*0e209d39SAndroid Build Coastguard Worker 
217*0e209d39SAndroid Build Coastguard Worker /**
218*0e209d39SAndroid Build Coastguard Worker  * Error value for all UTFs. This code point value will be set by macros with error
219*0e209d39SAndroid Build Coastguard Worker  * checking if an error is detected.
220*0e209d39SAndroid Build Coastguard Worker  *
221*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
222*0e209d39SAndroid Build Coastguard Worker  */
223*0e209d39SAndroid Build Coastguard Worker #define UTF_ERROR_VALUE 0xffff
224*0e209d39SAndroid Build Coastguard Worker 
225*0e209d39SAndroid Build Coastguard Worker /**
226*0e209d39SAndroid Build Coastguard Worker  * Is a given 32-bit code an error value
227*0e209d39SAndroid Build Coastguard Worker  * as returned by one of the macros for any UTF?
228*0e209d39SAndroid Build Coastguard Worker  *
229*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
230*0e209d39SAndroid Build Coastguard Worker  */
231*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_ERROR(c) \
232*0e209d39SAndroid Build Coastguard Worker     (((c)&0xfffe)==0xfffe || (c)==UTF8_ERROR_VALUE_1 || (c)==UTF8_ERROR_VALUE_2)
233*0e209d39SAndroid Build Coastguard Worker 
234*0e209d39SAndroid Build Coastguard Worker /**
235*0e209d39SAndroid Build Coastguard Worker  * This is a combined macro: Is c a valid Unicode value _and_ not an error code?
236*0e209d39SAndroid Build Coastguard Worker  *
237*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
238*0e209d39SAndroid Build Coastguard Worker  */
239*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_VALID(c) \
240*0e209d39SAndroid Build Coastguard Worker     (UTF_IS_UNICODE_CHAR(c) && \
241*0e209d39SAndroid Build Coastguard Worker      (c)!=UTF8_ERROR_VALUE_1 && (c)!=UTF8_ERROR_VALUE_2)
242*0e209d39SAndroid Build Coastguard Worker 
243*0e209d39SAndroid Build Coastguard Worker /**
244*0e209d39SAndroid Build Coastguard Worker  * Is this code unit or code point a surrogate (U+d800..U+dfff)?
245*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U_IS_SURROGATE and U16_IS_SURROGATE, see utf_old.h.
246*0e209d39SAndroid Build Coastguard Worker  */
247*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_SURROGATE(uchar) (((uchar)&0xfffff800)==0xd800)
248*0e209d39SAndroid Build Coastguard Worker 
249*0e209d39SAndroid Build Coastguard Worker /**
250*0e209d39SAndroid Build Coastguard Worker  * Is a given 32-bit code point a Unicode noncharacter?
251*0e209d39SAndroid Build Coastguard Worker  *
252*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_NONCHAR, see utf_old.h.
253*0e209d39SAndroid Build Coastguard Worker  */
254*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_UNICODE_NONCHAR(c) \
255*0e209d39SAndroid Build Coastguard Worker     ((c)>=0xfdd0 && \
256*0e209d39SAndroid Build Coastguard Worker      ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \
257*0e209d39SAndroid Build Coastguard Worker      (uint32_t)(c)<=0x10ffff)
258*0e209d39SAndroid Build Coastguard Worker 
259*0e209d39SAndroid Build Coastguard Worker /**
260*0e209d39SAndroid Build Coastguard Worker  * Is a given 32-bit value a Unicode code point value (0..U+10ffff)
261*0e209d39SAndroid Build Coastguard Worker  * that can be assigned a character?
262*0e209d39SAndroid Build Coastguard Worker  *
263*0e209d39SAndroid Build Coastguard Worker  * Code points that are not characters include:
264*0e209d39SAndroid Build Coastguard Worker  * - single surrogate code points (U+d800..U+dfff, 2048 code points)
265*0e209d39SAndroid Build Coastguard Worker  * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
266*0e209d39SAndroid Build Coastguard Worker  * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
267*0e209d39SAndroid Build Coastguard Worker  * - the highest Unicode code point value is U+10ffff
268*0e209d39SAndroid Build Coastguard Worker  *
269*0e209d39SAndroid Build Coastguard Worker  * This means that all code points below U+d800 are character code points,
270*0e209d39SAndroid Build Coastguard Worker  * and that boundary is tested first for performance.
271*0e209d39SAndroid Build Coastguard Worker  *
272*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_CHAR, see utf_old.h.
273*0e209d39SAndroid Build Coastguard Worker  */
274*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_UNICODE_CHAR(c) \
275*0e209d39SAndroid Build Coastguard Worker     ((uint32_t)(c)<0xd800 || \
276*0e209d39SAndroid Build Coastguard Worker         ((uint32_t)(c)>0xdfff && \
277*0e209d39SAndroid Build Coastguard Worker          (uint32_t)(c)<=0x10ffff && \
278*0e209d39SAndroid Build Coastguard Worker          !UTF_IS_UNICODE_NONCHAR(c)))
279*0e209d39SAndroid Build Coastguard Worker 
280*0e209d39SAndroid Build Coastguard Worker /* Formerly utf8.h ---------------------------------------------------------- */
281*0e209d39SAndroid Build Coastguard Worker 
282*0e209d39SAndroid Build Coastguard Worker /**
283*0e209d39SAndroid Build Coastguard Worker * \var utf8_countTrailBytes
284*0e209d39SAndroid Build Coastguard Worker * Internal array with numbers of trail bytes for any given byte used in
285*0e209d39SAndroid Build Coastguard Worker * lead byte position.
286*0e209d39SAndroid Build Coastguard Worker *
287*0e209d39SAndroid Build Coastguard Worker * This is internal since it is not meant to be called directly by external clients;
288*0e209d39SAndroid Build Coastguard Worker * however it is called by public macros in this file and thus must remain stable,
289*0e209d39SAndroid Build Coastguard Worker * and should not be hidden when other internal functions are hidden (otherwise
290*0e209d39SAndroid Build Coastguard Worker * public macros would fail to compile).
291*0e209d39SAndroid Build Coastguard Worker * @internal
292*0e209d39SAndroid Build Coastguard Worker */
293*0e209d39SAndroid Build Coastguard Worker #ifdef U_UTF8_IMPL
294*0e209d39SAndroid Build Coastguard Worker // No forward declaration if compiling utf_impl.cpp, which defines utf8_countTrailBytes.
295*0e209d39SAndroid Build Coastguard Worker #elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION)
296*0e209d39SAndroid Build Coastguard Worker U_CAPI const uint8_t utf8_countTrailBytes[];
297*0e209d39SAndroid Build Coastguard Worker #else
298*0e209d39SAndroid Build Coastguard Worker U_CFUNC U_IMPORT const uint8_t utf8_countTrailBytes[];
299*0e209d39SAndroid Build Coastguard Worker #endif
300*0e209d39SAndroid Build Coastguard Worker 
301*0e209d39SAndroid Build Coastguard Worker /**
302*0e209d39SAndroid Build Coastguard Worker  * Count the trail bytes for a UTF-8 lead byte.
303*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U8_COUNT_TRAIL_BYTES, see utf_old.h.
304*0e209d39SAndroid Build Coastguard Worker  */
305*0e209d39SAndroid Build Coastguard Worker #define UTF8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])
306*0e209d39SAndroid Build Coastguard Worker 
307*0e209d39SAndroid Build Coastguard Worker /**
308*0e209d39SAndroid Build Coastguard Worker  * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.
309*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U8_MASK_LEAD_BYTE, see utf_old.h.
310*0e209d39SAndroid Build Coastguard Worker  */
311*0e209d39SAndroid Build Coastguard Worker #define UTF8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)
312*0e209d39SAndroid Build Coastguard Worker 
313*0e209d39SAndroid Build Coastguard Worker /** Is this this code point a single code unit (byte)? @deprecated ICU 2.4. Renamed to U8_IS_SINGLE, see utf_old.h. */
314*0e209d39SAndroid Build Coastguard Worker #define UTF8_IS_SINGLE(uchar) (((uchar)&0x80)==0)
315*0e209d39SAndroid Build Coastguard Worker /** Is this this code unit the lead code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_LEAD, see utf_old.h. */
316*0e209d39SAndroid Build Coastguard Worker #define UTF8_IS_LEAD(uchar) ((uint8_t)((uchar)-0xc0)<0x3e)
317*0e209d39SAndroid Build Coastguard Worker /** Is this this code unit a trailing code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_TRAIL, see utf_old.h. */
318*0e209d39SAndroid Build Coastguard Worker #define UTF8_IS_TRAIL(uchar) (((uchar)&0xc0)==0x80)
319*0e209d39SAndroid Build Coastguard Worker 
320*0e209d39SAndroid Build Coastguard Worker /** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U8_LENGTH or test ((uint32_t)(c)>0x7f) instead, see utf_old.h. */
321*0e209d39SAndroid Build Coastguard Worker #define UTF8_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0x7f)
322*0e209d39SAndroid Build Coastguard Worker 
323*0e209d39SAndroid Build Coastguard Worker /**
324*0e209d39SAndroid Build Coastguard Worker  * Given the lead character, how many bytes are taken by this code point.
325*0e209d39SAndroid Build Coastguard Worker  * ICU does not deal with code points >0x10ffff
326*0e209d39SAndroid Build Coastguard Worker  * unless necessary for advancing in the byte stream.
327*0e209d39SAndroid Build Coastguard Worker  *
328*0e209d39SAndroid Build Coastguard Worker  * These length macros take into account that for values >0x10ffff
329*0e209d39SAndroid Build Coastguard Worker  * the UTF8_APPEND_CHAR_SAFE macros would write the error code point 0xffff
330*0e209d39SAndroid Build Coastguard Worker  * with 3 bytes.
331*0e209d39SAndroid Build Coastguard Worker  * Code point comparisons need to be in uint32_t because UChar32
332*0e209d39SAndroid Build Coastguard Worker  * may be a signed type, and negative values must be recognized.
333*0e209d39SAndroid Build Coastguard Worker  *
334*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Use U8_LENGTH instead, see utf.h.
335*0e209d39SAndroid Build Coastguard Worker  */
336*0e209d39SAndroid Build Coastguard Worker #if 1
337*0e209d39SAndroid Build Coastguard Worker #   define UTF8_CHAR_LENGTH(c) \
338*0e209d39SAndroid Build Coastguard Worker         ((uint32_t)(c)<=0x7f ? 1 : \
339*0e209d39SAndroid Build Coastguard Worker             ((uint32_t)(c)<=0x7ff ? 2 : \
340*0e209d39SAndroid Build Coastguard Worker                 ((uint32_t)((c)-0x10000)>0xfffff ? 3 : 4) \
341*0e209d39SAndroid Build Coastguard Worker             ) \
342*0e209d39SAndroid Build Coastguard Worker         )
343*0e209d39SAndroid Build Coastguard Worker #else
344*0e209d39SAndroid Build Coastguard Worker #   define UTF8_CHAR_LENGTH(c) \
345*0e209d39SAndroid Build Coastguard Worker         ((uint32_t)(c)<=0x7f ? 1 : \
346*0e209d39SAndroid Build Coastguard Worker             ((uint32_t)(c)<=0x7ff ? 2 : \
347*0e209d39SAndroid Build Coastguard Worker                 ((uint32_t)(c)<=0xffff ? 3 : \
348*0e209d39SAndroid Build Coastguard Worker                     ((uint32_t)(c)<=0x10ffff ? 4 : \
349*0e209d39SAndroid Build Coastguard Worker                         ((uint32_t)(c)<=0x3ffffff ? 5 : \
350*0e209d39SAndroid Build Coastguard Worker                             ((uint32_t)(c)<=0x7fffffff ? 6 : 3) \
351*0e209d39SAndroid Build Coastguard Worker                         ) \
352*0e209d39SAndroid Build Coastguard Worker                     ) \
353*0e209d39SAndroid Build Coastguard Worker                 ) \
354*0e209d39SAndroid Build Coastguard Worker             ) \
355*0e209d39SAndroid Build Coastguard Worker         )
356*0e209d39SAndroid Build Coastguard Worker #endif
357*0e209d39SAndroid Build Coastguard Worker 
358*0e209d39SAndroid Build Coastguard Worker /** The maximum number of bytes per code point. @deprecated ICU 2.4. Renamed to U8_MAX_LENGTH, see utf_old.h. */
359*0e209d39SAndroid Build Coastguard Worker #define UTF8_MAX_CHAR_LENGTH 4
360*0e209d39SAndroid Build Coastguard Worker 
361*0e209d39SAndroid Build Coastguard Worker /** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
362*0e209d39SAndroid Build Coastguard Worker #define UTF8_ARRAY_SIZE(size) ((5*(size))/2)
363*0e209d39SAndroid Build Coastguard Worker 
364*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */
365*0e209d39SAndroid Build Coastguard Worker #define UTF8_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
366*0e209d39SAndroid Build Coastguard Worker     int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \
367*0e209d39SAndroid Build Coastguard Worker     UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \
368*0e209d39SAndroid Build Coastguard Worker     UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \
369*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
370*0e209d39SAndroid Build Coastguard Worker 
371*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */
372*0e209d39SAndroid Build Coastguard Worker #define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
373*0e209d39SAndroid Build Coastguard Worker     int32_t _utf8_get_char_safe_index=(int32_t)(i); \
374*0e209d39SAndroid Build Coastguard Worker     UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \
375*0e209d39SAndroid Build Coastguard Worker     UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \
376*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
377*0e209d39SAndroid Build Coastguard Worker 
378*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */
379*0e209d39SAndroid Build Coastguard Worker #define UTF8_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
380*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[(i)++]; \
381*0e209d39SAndroid Build Coastguard Worker     if((uint8_t)((c)-0xc0)<0x35) { \
382*0e209d39SAndroid Build Coastguard Worker         uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \
383*0e209d39SAndroid Build Coastguard Worker         UTF8_MASK_LEAD_BYTE(c, __count); \
384*0e209d39SAndroid Build Coastguard Worker         switch(__count) { \
385*0e209d39SAndroid Build Coastguard Worker         /* each following branch falls through to the next one */ \
386*0e209d39SAndroid Build Coastguard Worker         case 3: \
387*0e209d39SAndroid Build Coastguard Worker             (c)=((c)<<6)|((s)[(i)++]&0x3f); \
388*0e209d39SAndroid Build Coastguard Worker         case 2: \
389*0e209d39SAndroid Build Coastguard Worker             (c)=((c)<<6)|((s)[(i)++]&0x3f); \
390*0e209d39SAndroid Build Coastguard Worker         case 1: \
391*0e209d39SAndroid Build Coastguard Worker             (c)=((c)<<6)|((s)[(i)++]&0x3f); \
392*0e209d39SAndroid Build Coastguard Worker         /* no other branches to optimize switch() */ \
393*0e209d39SAndroid Build Coastguard Worker             break; \
394*0e209d39SAndroid Build Coastguard Worker         } \
395*0e209d39SAndroid Build Coastguard Worker     } \
396*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
397*0e209d39SAndroid Build Coastguard Worker 
398*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */
399*0e209d39SAndroid Build Coastguard Worker #define UTF8_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
400*0e209d39SAndroid Build Coastguard Worker     if((uint32_t)(c)<=0x7f) { \
401*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint8_t)(c); \
402*0e209d39SAndroid Build Coastguard Worker     } else { \
403*0e209d39SAndroid Build Coastguard Worker         if((uint32_t)(c)<=0x7ff) { \
404*0e209d39SAndroid Build Coastguard Worker             (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \
405*0e209d39SAndroid Build Coastguard Worker         } else { \
406*0e209d39SAndroid Build Coastguard Worker             if((uint32_t)(c)<=0xffff) { \
407*0e209d39SAndroid Build Coastguard Worker                 (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \
408*0e209d39SAndroid Build Coastguard Worker             } else { \
409*0e209d39SAndroid Build Coastguard Worker                 (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \
410*0e209d39SAndroid Build Coastguard Worker                 (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \
411*0e209d39SAndroid Build Coastguard Worker             } \
412*0e209d39SAndroid Build Coastguard Worker             (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \
413*0e209d39SAndroid Build Coastguard Worker         } \
414*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
415*0e209d39SAndroid Build Coastguard Worker     } \
416*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
417*0e209d39SAndroid Build Coastguard Worker 
418*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */
419*0e209d39SAndroid Build Coastguard Worker #define UTF8_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
420*0e209d39SAndroid Build Coastguard Worker     (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \
421*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
422*0e209d39SAndroid Build Coastguard Worker 
423*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */
424*0e209d39SAndroid Build Coastguard Worker #define UTF8_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
425*0e209d39SAndroid Build Coastguard Worker     int32_t __N=(n); \
426*0e209d39SAndroid Build Coastguard Worker     while(__N>0) { \
427*0e209d39SAndroid Build Coastguard Worker         UTF8_FWD_1_UNSAFE(s, i); \
428*0e209d39SAndroid Build Coastguard Worker         --__N; \
429*0e209d39SAndroid Build Coastguard Worker     } \
430*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
431*0e209d39SAndroid Build Coastguard Worker 
432*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */
433*0e209d39SAndroid Build Coastguard Worker #define UTF8_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
434*0e209d39SAndroid Build Coastguard Worker     while(UTF8_IS_TRAIL((s)[i])) { --(i); } \
435*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
436*0e209d39SAndroid Build Coastguard Worker 
437*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */
438*0e209d39SAndroid Build Coastguard Worker #define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
439*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[(i)++]; \
440*0e209d39SAndroid Build Coastguard Worker     if((c)>=0x80) { \
441*0e209d39SAndroid Build Coastguard Worker         if(UTF8_IS_LEAD(c)) { \
442*0e209d39SAndroid Build Coastguard Worker             (c)=utf8_nextCharSafeBody(s, &(i), (int32_t)(length), c, strict); \
443*0e209d39SAndroid Build Coastguard Worker         } else { \
444*0e209d39SAndroid Build Coastguard Worker             (c)=UTF8_ERROR_VALUE_1; \
445*0e209d39SAndroid Build Coastguard Worker         } \
446*0e209d39SAndroid Build Coastguard Worker     } \
447*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
448*0e209d39SAndroid Build Coastguard Worker 
449*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */
450*0e209d39SAndroid Build Coastguard Worker #define UTF8_APPEND_CHAR_SAFE(s, i, length, c)  UPRV_BLOCK_MACRO_BEGIN { \
451*0e209d39SAndroid Build Coastguard Worker     if((uint32_t)(c)<=0x7f) { \
452*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint8_t)(c); \
453*0e209d39SAndroid Build Coastguard Worker     } else { \
454*0e209d39SAndroid Build Coastguard Worker         (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \
455*0e209d39SAndroid Build Coastguard Worker     } \
456*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
457*0e209d39SAndroid Build Coastguard Worker 
458*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */
459*0e209d39SAndroid Build Coastguard Worker #define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length)
460*0e209d39SAndroid Build Coastguard Worker 
461*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_FWD_N, see utf_old.h. */
462*0e209d39SAndroid Build Coastguard Worker #define UTF8_FWD_N_SAFE(s, i, length, n) U8_FWD_N(s, i, length, n)
463*0e209d39SAndroid Build Coastguard Worker 
464*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_SET_CP_START, see utf_old.h. */
465*0e209d39SAndroid Build Coastguard Worker #define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i)
466*0e209d39SAndroid Build Coastguard Worker 
467*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */
468*0e209d39SAndroid Build Coastguard Worker #define UTF8_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
469*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[--(i)]; \
470*0e209d39SAndroid Build Coastguard Worker     if(UTF8_IS_TRAIL(c)) { \
471*0e209d39SAndroid Build Coastguard Worker         uint8_t __b, __count=1, __shift=6; \
472*0e209d39SAndroid Build Coastguard Worker \
473*0e209d39SAndroid Build Coastguard Worker         /* c is a trail byte */ \
474*0e209d39SAndroid Build Coastguard Worker         (c)&=0x3f; \
475*0e209d39SAndroid Build Coastguard Worker         for(;;) { \
476*0e209d39SAndroid Build Coastguard Worker             __b=(s)[--(i)]; \
477*0e209d39SAndroid Build Coastguard Worker             if(__b>=0xc0) { \
478*0e209d39SAndroid Build Coastguard Worker                 UTF8_MASK_LEAD_BYTE(__b, __count); \
479*0e209d39SAndroid Build Coastguard Worker                 (c)|=(UChar32)__b<<__shift; \
480*0e209d39SAndroid Build Coastguard Worker                 break; \
481*0e209d39SAndroid Build Coastguard Worker             } else { \
482*0e209d39SAndroid Build Coastguard Worker                 (c)|=(UChar32)(__b&0x3f)<<__shift; \
483*0e209d39SAndroid Build Coastguard Worker                 ++__count; \
484*0e209d39SAndroid Build Coastguard Worker                 __shift+=6; \
485*0e209d39SAndroid Build Coastguard Worker             } \
486*0e209d39SAndroid Build Coastguard Worker         } \
487*0e209d39SAndroid Build Coastguard Worker     } \
488*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
489*0e209d39SAndroid Build Coastguard Worker 
490*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */
491*0e209d39SAndroid Build Coastguard Worker #define UTF8_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
492*0e209d39SAndroid Build Coastguard Worker     while(UTF8_IS_TRAIL((s)[--(i)])) {} \
493*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
494*0e209d39SAndroid Build Coastguard Worker 
495*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */
496*0e209d39SAndroid Build Coastguard Worker #define UTF8_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
497*0e209d39SAndroid Build Coastguard Worker     int32_t __N=(n); \
498*0e209d39SAndroid Build Coastguard Worker     while(__N>0) { \
499*0e209d39SAndroid Build Coastguard Worker         UTF8_BACK_1_UNSAFE(s, i); \
500*0e209d39SAndroid Build Coastguard Worker         --__N; \
501*0e209d39SAndroid Build Coastguard Worker     } \
502*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
503*0e209d39SAndroid Build Coastguard Worker 
504*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
505*0e209d39SAndroid Build Coastguard Worker #define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
506*0e209d39SAndroid Build Coastguard Worker     UTF8_BACK_1_UNSAFE(s, i); \
507*0e209d39SAndroid Build Coastguard Worker     UTF8_FWD_1_UNSAFE(s, i); \
508*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
509*0e209d39SAndroid Build Coastguard Worker 
510*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */
511*0e209d39SAndroid Build Coastguard Worker #define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
512*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[--(i)]; \
513*0e209d39SAndroid Build Coastguard Worker     if((c)>=0x80) { \
514*0e209d39SAndroid Build Coastguard Worker         if((c)<=0xbf) { \
515*0e209d39SAndroid Build Coastguard Worker             (c)=utf8_prevCharSafeBody(s, start, &(i), c, strict); \
516*0e209d39SAndroid Build Coastguard Worker         } else { \
517*0e209d39SAndroid Build Coastguard Worker             (c)=UTF8_ERROR_VALUE_1; \
518*0e209d39SAndroid Build Coastguard Worker         } \
519*0e209d39SAndroid Build Coastguard Worker     } \
520*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
521*0e209d39SAndroid Build Coastguard Worker 
522*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */
523*0e209d39SAndroid Build Coastguard Worker #define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i)
524*0e209d39SAndroid Build Coastguard Worker 
525*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_BACK_N, see utf_old.h. */
526*0e209d39SAndroid Build Coastguard Worker #define UTF8_BACK_N_SAFE(s, start, i, n) U8_BACK_N(s, start, i, n)
527*0e209d39SAndroid Build Coastguard Worker 
528*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT, see utf_old.h. */
529*0e209d39SAndroid Build Coastguard Worker #define UTF8_SET_CHAR_LIMIT_SAFE(s, start, i, length) U8_SET_CP_LIMIT(s, start, i, length)
530*0e209d39SAndroid Build Coastguard Worker 
531*0e209d39SAndroid Build Coastguard Worker /* Formerly utf16.h --------------------------------------------------------- */
532*0e209d39SAndroid Build Coastguard Worker 
533*0e209d39SAndroid Build Coastguard Worker /** Is uchar a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h. */
534*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_FIRST_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xd800)
535*0e209d39SAndroid Build Coastguard Worker 
536*0e209d39SAndroid Build Coastguard Worker /** Is uchar a second/trail surrogate? @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h. */
537*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_SECOND_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xdc00)
538*0e209d39SAndroid Build Coastguard Worker 
539*0e209d39SAndroid Build Coastguard Worker /** Assuming c is a surrogate, is it a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_SURROGATE_LEAD and U16_IS_SURROGATE_LEAD, see utf_old.h. */
540*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_SURROGATE_FIRST(c) (((c)&0x400)==0)
541*0e209d39SAndroid Build Coastguard Worker 
542*0e209d39SAndroid Build Coastguard Worker /** Helper constant for UTF16_GET_PAIR_VALUE. @deprecated ICU 2.4. Renamed to U16_SURROGATE_OFFSET, see utf_old.h. */
543*0e209d39SAndroid Build Coastguard Worker #define UTF_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
544*0e209d39SAndroid Build Coastguard Worker 
545*0e209d39SAndroid Build Coastguard Worker /** Get the UTF-32 value from the surrogate code units. @deprecated ICU 2.4. Renamed to U16_GET_SUPPLEMENTARY, see utf_old.h. */
546*0e209d39SAndroid Build Coastguard Worker #define UTF16_GET_PAIR_VALUE(first, second) \
547*0e209d39SAndroid Build Coastguard Worker     (((first)<<10UL)+(second)-UTF_SURROGATE_OFFSET)
548*0e209d39SAndroid Build Coastguard Worker 
549*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */
550*0e209d39SAndroid Build Coastguard Worker #define UTF_FIRST_SURROGATE(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)
551*0e209d39SAndroid Build Coastguard Worker 
552*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */
553*0e209d39SAndroid Build Coastguard Worker #define UTF_SECOND_SURROGATE(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)
554*0e209d39SAndroid Build Coastguard Worker 
555*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */
556*0e209d39SAndroid Build Coastguard Worker #define UTF16_LEAD(supplementary) UTF_FIRST_SURROGATE(supplementary)
557*0e209d39SAndroid Build Coastguard Worker 
558*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */
559*0e209d39SAndroid Build Coastguard Worker #define UTF16_TRAIL(supplementary) UTF_SECOND_SURROGATE(supplementary)
560*0e209d39SAndroid Build Coastguard Worker 
561*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_IS_SINGLE, see utf_old.h. */
562*0e209d39SAndroid Build Coastguard Worker #define UTF16_IS_SINGLE(uchar) !UTF_IS_SURROGATE(uchar)
563*0e209d39SAndroid Build Coastguard Worker 
564*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_IS_LEAD, see utf_old.h. */
565*0e209d39SAndroid Build Coastguard Worker #define UTF16_IS_LEAD(uchar) UTF_IS_FIRST_SURROGATE(uchar)
566*0e209d39SAndroid Build Coastguard Worker 
567*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_IS_TRAIL, see utf_old.h. */
568*0e209d39SAndroid Build Coastguard Worker #define UTF16_IS_TRAIL(uchar) UTF_IS_SECOND_SURROGATE(uchar)
569*0e209d39SAndroid Build Coastguard Worker 
570*0e209d39SAndroid Build Coastguard Worker /** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead, see utf_old.h. */
571*0e209d39SAndroid Build Coastguard Worker #define UTF16_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0xffff)
572*0e209d39SAndroid Build Coastguard Worker 
573*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h. */
574*0e209d39SAndroid Build Coastguard Worker #define UTF16_CHAR_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
575*0e209d39SAndroid Build Coastguard Worker 
576*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h. */
577*0e209d39SAndroid Build Coastguard Worker #define UTF16_MAX_CHAR_LENGTH 2
578*0e209d39SAndroid Build Coastguard Worker 
579*0e209d39SAndroid Build Coastguard Worker /** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
580*0e209d39SAndroid Build Coastguard Worker #define UTF16_ARRAY_SIZE(size) (size)
581*0e209d39SAndroid Build Coastguard Worker 
582*0e209d39SAndroid Build Coastguard Worker /**
583*0e209d39SAndroid Build Coastguard Worker  * Get a single code point from an offset that points to any
584*0e209d39SAndroid Build Coastguard Worker  * of the code units that belong to that code point.
585*0e209d39SAndroid Build Coastguard Worker  * Assume 0<=i<length.
586*0e209d39SAndroid Build Coastguard Worker  *
587*0e209d39SAndroid Build Coastguard Worker  * This could be used for iteration together with
588*0e209d39SAndroid Build Coastguard Worker  * UTF16_CHAR_LENGTH() and UTF_IS_ERROR(),
589*0e209d39SAndroid Build Coastguard Worker  * but the use of UTF16_NEXT_CHAR[_UNSAFE]() and
590*0e209d39SAndroid Build Coastguard Worker  * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that.
591*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h.
592*0e209d39SAndroid Build Coastguard Worker  */
593*0e209d39SAndroid Build Coastguard Worker #define UTF16_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
594*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[i]; \
595*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_SURROGATE(c)) { \
596*0e209d39SAndroid Build Coastguard Worker         if(UTF_IS_SURROGATE_FIRST(c)) { \
597*0e209d39SAndroid Build Coastguard Worker             (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)+1]); \
598*0e209d39SAndroid Build Coastguard Worker         } else { \
599*0e209d39SAndroid Build Coastguard Worker             (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \
600*0e209d39SAndroid Build Coastguard Worker         } \
601*0e209d39SAndroid Build Coastguard Worker     } \
602*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
603*0e209d39SAndroid Build Coastguard Worker 
604*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */
605*0e209d39SAndroid Build Coastguard Worker #define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
606*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[i]; \
607*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_SURROGATE(c)) { \
608*0e209d39SAndroid Build Coastguard Worker         uint16_t __c2; \
609*0e209d39SAndroid Build Coastguard Worker         if(UTF_IS_SURROGATE_FIRST(c)) { \
610*0e209d39SAndroid Build Coastguard Worker             if((i)+1<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)+1])) { \
611*0e209d39SAndroid Build Coastguard Worker                 (c)=UTF16_GET_PAIR_VALUE((c), __c2); \
612*0e209d39SAndroid Build Coastguard Worker                 /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
613*0e209d39SAndroid Build Coastguard Worker             } else if(strict) {\
614*0e209d39SAndroid Build Coastguard Worker                 /* unmatched first surrogate */ \
615*0e209d39SAndroid Build Coastguard Worker                 (c)=UTF_ERROR_VALUE; \
616*0e209d39SAndroid Build Coastguard Worker             } \
617*0e209d39SAndroid Build Coastguard Worker         } else { \
618*0e209d39SAndroid Build Coastguard Worker             if((i)-1>=(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
619*0e209d39SAndroid Build Coastguard Worker                 (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
620*0e209d39SAndroid Build Coastguard Worker                 /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
621*0e209d39SAndroid Build Coastguard Worker             } else if(strict) {\
622*0e209d39SAndroid Build Coastguard Worker                 /* unmatched second surrogate */ \
623*0e209d39SAndroid Build Coastguard Worker                 (c)=UTF_ERROR_VALUE; \
624*0e209d39SAndroid Build Coastguard Worker             } \
625*0e209d39SAndroid Build Coastguard Worker         } \
626*0e209d39SAndroid Build Coastguard Worker     } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
627*0e209d39SAndroid Build Coastguard Worker         (c)=UTF_ERROR_VALUE; \
628*0e209d39SAndroid Build Coastguard Worker     } \
629*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
630*0e209d39SAndroid Build Coastguard Worker 
631*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */
632*0e209d39SAndroid Build Coastguard Worker #define UTF16_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
633*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[(i)++]; \
634*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_FIRST_SURROGATE(c)) { \
635*0e209d39SAndroid Build Coastguard Worker         (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \
636*0e209d39SAndroid Build Coastguard Worker     } \
637*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
638*0e209d39SAndroid Build Coastguard Worker 
639*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */
640*0e209d39SAndroid Build Coastguard Worker #define UTF16_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
641*0e209d39SAndroid Build Coastguard Worker     if((uint32_t)(c)<=0xffff) { \
642*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint16_t)(c); \
643*0e209d39SAndroid Build Coastguard Worker     } else { \
644*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
645*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
646*0e209d39SAndroid Build Coastguard Worker     } \
647*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
648*0e209d39SAndroid Build Coastguard Worker 
649*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */
650*0e209d39SAndroid Build Coastguard Worker #define UTF16_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
651*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \
652*0e209d39SAndroid Build Coastguard Worker         ++(i); \
653*0e209d39SAndroid Build Coastguard Worker     } \
654*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
655*0e209d39SAndroid Build Coastguard Worker 
656*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */
657*0e209d39SAndroid Build Coastguard Worker #define UTF16_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
658*0e209d39SAndroid Build Coastguard Worker     int32_t __N=(n); \
659*0e209d39SAndroid Build Coastguard Worker     while(__N>0) { \
660*0e209d39SAndroid Build Coastguard Worker         UTF16_FWD_1_UNSAFE(s, i); \
661*0e209d39SAndroid Build Coastguard Worker         --__N; \
662*0e209d39SAndroid Build Coastguard Worker     } \
663*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
664*0e209d39SAndroid Build Coastguard Worker 
665*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */
666*0e209d39SAndroid Build Coastguard Worker #define UTF16_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
667*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_SECOND_SURROGATE((s)[i])) { \
668*0e209d39SAndroid Build Coastguard Worker         --(i); \
669*0e209d39SAndroid Build Coastguard Worker     } \
670*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
671*0e209d39SAndroid Build Coastguard Worker 
672*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */
673*0e209d39SAndroid Build Coastguard Worker #define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
674*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[(i)++]; \
675*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_FIRST_SURROGATE(c)) { \
676*0e209d39SAndroid Build Coastguard Worker         uint16_t __c2; \
677*0e209d39SAndroid Build Coastguard Worker         if((i)<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)])) { \
678*0e209d39SAndroid Build Coastguard Worker             ++(i); \
679*0e209d39SAndroid Build Coastguard Worker             (c)=UTF16_GET_PAIR_VALUE((c), __c2); \
680*0e209d39SAndroid Build Coastguard Worker             /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
681*0e209d39SAndroid Build Coastguard Worker         } else if(strict) {\
682*0e209d39SAndroid Build Coastguard Worker             /* unmatched first surrogate */ \
683*0e209d39SAndroid Build Coastguard Worker             (c)=UTF_ERROR_VALUE; \
684*0e209d39SAndroid Build Coastguard Worker         } \
685*0e209d39SAndroid Build Coastguard Worker     } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
686*0e209d39SAndroid Build Coastguard Worker         /* unmatched second surrogate or other non-character */ \
687*0e209d39SAndroid Build Coastguard Worker         (c)=UTF_ERROR_VALUE; \
688*0e209d39SAndroid Build Coastguard Worker     } \
689*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
690*0e209d39SAndroid Build Coastguard Worker 
691*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */
692*0e209d39SAndroid Build Coastguard Worker #define UTF16_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
693*0e209d39SAndroid Build Coastguard Worker     if((uint32_t)(c)<=0xffff) { \
694*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(uint16_t)(c); \
695*0e209d39SAndroid Build Coastguard Worker     } else if((uint32_t)(c)<=0x10ffff) { \
696*0e209d39SAndroid Build Coastguard Worker         if((i)+1<(length)) { \
697*0e209d39SAndroid Build Coastguard Worker             (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
698*0e209d39SAndroid Build Coastguard Worker             (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
699*0e209d39SAndroid Build Coastguard Worker         } else /* not enough space */ { \
700*0e209d39SAndroid Build Coastguard Worker             (s)[(i)++]=UTF_ERROR_VALUE; \
701*0e209d39SAndroid Build Coastguard Worker         } \
702*0e209d39SAndroid Build Coastguard Worker     } else /* c>0x10ffff, write error value */ { \
703*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=UTF_ERROR_VALUE; \
704*0e209d39SAndroid Build Coastguard Worker     } \
705*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
706*0e209d39SAndroid Build Coastguard Worker 
707*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */
708*0e209d39SAndroid Build Coastguard Worker #define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length)
709*0e209d39SAndroid Build Coastguard Worker 
710*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */
711*0e209d39SAndroid Build Coastguard Worker #define UTF16_FWD_N_SAFE(s, i, length, n) U16_FWD_N(s, i, length, n)
712*0e209d39SAndroid Build Coastguard Worker 
713*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */
714*0e209d39SAndroid Build Coastguard Worker #define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i)
715*0e209d39SAndroid Build Coastguard Worker 
716*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */
717*0e209d39SAndroid Build Coastguard Worker #define UTF16_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
718*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[--(i)]; \
719*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_SECOND_SURROGATE(c)) { \
720*0e209d39SAndroid Build Coastguard Worker         (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \
721*0e209d39SAndroid Build Coastguard Worker     } \
722*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
723*0e209d39SAndroid Build Coastguard Worker 
724*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */
725*0e209d39SAndroid Build Coastguard Worker #define UTF16_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
726*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \
727*0e209d39SAndroid Build Coastguard Worker         --(i); \
728*0e209d39SAndroid Build Coastguard Worker     } \
729*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
730*0e209d39SAndroid Build Coastguard Worker 
731*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */
732*0e209d39SAndroid Build Coastguard Worker #define UTF16_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
733*0e209d39SAndroid Build Coastguard Worker     int32_t __N=(n); \
734*0e209d39SAndroid Build Coastguard Worker     while(__N>0) { \
735*0e209d39SAndroid Build Coastguard Worker         UTF16_BACK_1_UNSAFE(s, i); \
736*0e209d39SAndroid Build Coastguard Worker         --__N; \
737*0e209d39SAndroid Build Coastguard Worker     } \
738*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
739*0e209d39SAndroid Build Coastguard Worker 
740*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
741*0e209d39SAndroid Build Coastguard Worker #define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
742*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \
743*0e209d39SAndroid Build Coastguard Worker         ++(i); \
744*0e209d39SAndroid Build Coastguard Worker     } \
745*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
746*0e209d39SAndroid Build Coastguard Worker 
747*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */
748*0e209d39SAndroid Build Coastguard Worker #define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
749*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[--(i)]; \
750*0e209d39SAndroid Build Coastguard Worker     if(UTF_IS_SECOND_SURROGATE(c)) { \
751*0e209d39SAndroid Build Coastguard Worker         uint16_t __c2; \
752*0e209d39SAndroid Build Coastguard Worker         if((i)>(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
753*0e209d39SAndroid Build Coastguard Worker             --(i); \
754*0e209d39SAndroid Build Coastguard Worker             (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
755*0e209d39SAndroid Build Coastguard Worker             /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
756*0e209d39SAndroid Build Coastguard Worker         } else if(strict) {\
757*0e209d39SAndroid Build Coastguard Worker             /* unmatched second surrogate */ \
758*0e209d39SAndroid Build Coastguard Worker             (c)=UTF_ERROR_VALUE; \
759*0e209d39SAndroid Build Coastguard Worker         } \
760*0e209d39SAndroid Build Coastguard Worker     } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
761*0e209d39SAndroid Build Coastguard Worker         /* unmatched first surrogate or other non-character */ \
762*0e209d39SAndroid Build Coastguard Worker         (c)=UTF_ERROR_VALUE; \
763*0e209d39SAndroid Build Coastguard Worker     } \
764*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
765*0e209d39SAndroid Build Coastguard Worker 
766*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */
767*0e209d39SAndroid Build Coastguard Worker #define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i)
768*0e209d39SAndroid Build Coastguard Worker 
769*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */
770*0e209d39SAndroid Build Coastguard Worker #define UTF16_BACK_N_SAFE(s, start, i, n) U16_BACK_N(s, start, i, n)
771*0e209d39SAndroid Build Coastguard Worker 
772*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */
773*0e209d39SAndroid Build Coastguard Worker #define UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
774*0e209d39SAndroid Build Coastguard Worker 
775*0e209d39SAndroid Build Coastguard Worker /* Formerly utf32.h --------------------------------------------------------- */
776*0e209d39SAndroid Build Coastguard Worker 
777*0e209d39SAndroid Build Coastguard Worker /*
778*0e209d39SAndroid Build Coastguard Worker * Old documentation:
779*0e209d39SAndroid Build Coastguard Worker *
780*0e209d39SAndroid Build Coastguard Worker *   This file defines macros to deal with UTF-32 code units and code points.
781*0e209d39SAndroid Build Coastguard Worker *   Signatures and semantics are the same as for the similarly named macros
782*0e209d39SAndroid Build Coastguard Worker *   in utf16.h.
783*0e209d39SAndroid Build Coastguard Worker *   utf32.h is included by utf.h after unicode/umachine.h</p>
784*0e209d39SAndroid Build Coastguard Worker *   and some common definitions.
785*0e209d39SAndroid Build Coastguard Worker *   <p><b>Usage:</b>  ICU coding guidelines for if() statements should be followed when using these macros.
786*0e209d39SAndroid Build Coastguard Worker *                  Compound statements (curly braces {}) must be used  for if-else-while...
787*0e209d39SAndroid Build Coastguard Worker *                  bodies and all macro statements should be terminated with semicolon.</p>
788*0e209d39SAndroid Build Coastguard Worker */
789*0e209d39SAndroid Build Coastguard Worker 
790*0e209d39SAndroid Build Coastguard Worker /* internal definitions ----------------------------------------------------- */
791*0e209d39SAndroid Build Coastguard Worker 
792*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
793*0e209d39SAndroid Build Coastguard Worker #define UTF32_IS_SAFE(c, strict) \
794*0e209d39SAndroid Build Coastguard Worker     (!(strict) ? \
795*0e209d39SAndroid Build Coastguard Worker         (uint32_t)(c)<=0x10ffff : \
796*0e209d39SAndroid Build Coastguard Worker         UTF_IS_UNICODE_CHAR(c))
797*0e209d39SAndroid Build Coastguard Worker 
798*0e209d39SAndroid Build Coastguard Worker /*
799*0e209d39SAndroid Build Coastguard Worker  * For the semantics of all of these macros, see utf16.h.
800*0e209d39SAndroid Build Coastguard Worker  * The UTF-32 versions are trivial because any code point is
801*0e209d39SAndroid Build Coastguard Worker  * encoded using exactly one code unit.
802*0e209d39SAndroid Build Coastguard Worker  */
803*0e209d39SAndroid Build Coastguard Worker 
804*0e209d39SAndroid Build Coastguard Worker /* single-code point definitions -------------------------------------------- */
805*0e209d39SAndroid Build Coastguard Worker 
806*0e209d39SAndroid Build Coastguard Worker /* classes of code unit values */
807*0e209d39SAndroid Build Coastguard Worker 
808*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
809*0e209d39SAndroid Build Coastguard Worker #define UTF32_IS_SINGLE(uchar) 1
810*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
811*0e209d39SAndroid Build Coastguard Worker #define UTF32_IS_LEAD(uchar) 0
812*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
813*0e209d39SAndroid Build Coastguard Worker #define UTF32_IS_TRAIL(uchar) 0
814*0e209d39SAndroid Build Coastguard Worker 
815*0e209d39SAndroid Build Coastguard Worker /* number of code units per code point */
816*0e209d39SAndroid Build Coastguard Worker 
817*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
818*0e209d39SAndroid Build Coastguard Worker #define UTF32_NEED_MULTIPLE_UCHAR(c) 0
819*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
820*0e209d39SAndroid Build Coastguard Worker #define UTF32_CHAR_LENGTH(c) 1
821*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
822*0e209d39SAndroid Build Coastguard Worker #define UTF32_MAX_CHAR_LENGTH 1
823*0e209d39SAndroid Build Coastguard Worker 
824*0e209d39SAndroid Build Coastguard Worker /* average number of code units compared to UTF-16 */
825*0e209d39SAndroid Build Coastguard Worker 
826*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
827*0e209d39SAndroid Build Coastguard Worker #define UTF32_ARRAY_SIZE(size) (size)
828*0e209d39SAndroid Build Coastguard Worker 
829*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
830*0e209d39SAndroid Build Coastguard Worker #define UTF32_GET_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
831*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[i]; \
832*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
833*0e209d39SAndroid Build Coastguard Worker 
834*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
835*0e209d39SAndroid Build Coastguard Worker #define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
836*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[i]; \
837*0e209d39SAndroid Build Coastguard Worker     if(!UTF32_IS_SAFE(c, strict)) { \
838*0e209d39SAndroid Build Coastguard Worker         (c)=UTF_ERROR_VALUE; \
839*0e209d39SAndroid Build Coastguard Worker     } \
840*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
841*0e209d39SAndroid Build Coastguard Worker 
842*0e209d39SAndroid Build Coastguard Worker /* definitions with forward iteration --------------------------------------- */
843*0e209d39SAndroid Build Coastguard Worker 
844*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
845*0e209d39SAndroid Build Coastguard Worker #define UTF32_NEXT_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
846*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[(i)++]; \
847*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
848*0e209d39SAndroid Build Coastguard Worker 
849*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
850*0e209d39SAndroid Build Coastguard Worker #define UTF32_APPEND_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
851*0e209d39SAndroid Build Coastguard Worker     (s)[(i)++]=(c); \
852*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
853*0e209d39SAndroid Build Coastguard Worker 
854*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
855*0e209d39SAndroid Build Coastguard Worker #define UTF32_FWD_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
856*0e209d39SAndroid Build Coastguard Worker     ++(i); \
857*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
858*0e209d39SAndroid Build Coastguard Worker 
859*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
860*0e209d39SAndroid Build Coastguard Worker #define UTF32_FWD_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
861*0e209d39SAndroid Build Coastguard Worker     (i)+=(n); \
862*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
863*0e209d39SAndroid Build Coastguard Worker 
864*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
865*0e209d39SAndroid Build Coastguard Worker #define UTF32_SET_CHAR_START_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
866*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
867*0e209d39SAndroid Build Coastguard Worker 
868*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
869*0e209d39SAndroid Build Coastguard Worker #define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
870*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[(i)++]; \
871*0e209d39SAndroid Build Coastguard Worker     if(!UTF32_IS_SAFE(c, strict)) { \
872*0e209d39SAndroid Build Coastguard Worker         (c)=UTF_ERROR_VALUE; \
873*0e209d39SAndroid Build Coastguard Worker     } \
874*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
875*0e209d39SAndroid Build Coastguard Worker 
876*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
877*0e209d39SAndroid Build Coastguard Worker #define UTF32_APPEND_CHAR_SAFE(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
878*0e209d39SAndroid Build Coastguard Worker     if((uint32_t)(c)<=0x10ffff) { \
879*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=(c); \
880*0e209d39SAndroid Build Coastguard Worker     } else /* c>0x10ffff, write 0xfffd */ { \
881*0e209d39SAndroid Build Coastguard Worker         (s)[(i)++]=0xfffd; \
882*0e209d39SAndroid Build Coastguard Worker     } \
883*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
884*0e209d39SAndroid Build Coastguard Worker 
885*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
886*0e209d39SAndroid Build Coastguard Worker #define UTF32_FWD_1_SAFE(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \
887*0e209d39SAndroid Build Coastguard Worker     ++(i); \
888*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
889*0e209d39SAndroid Build Coastguard Worker 
890*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
891*0e209d39SAndroid Build Coastguard Worker #define UTF32_FWD_N_SAFE(s, i, length, n) UPRV_BLOCK_MACRO_BEGIN { \
892*0e209d39SAndroid Build Coastguard Worker     if(((i)+=(n))>(length)) { \
893*0e209d39SAndroid Build Coastguard Worker         (i)=(length); \
894*0e209d39SAndroid Build Coastguard Worker     } \
895*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
896*0e209d39SAndroid Build Coastguard Worker 
897*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
898*0e209d39SAndroid Build Coastguard Worker #define UTF32_SET_CHAR_START_SAFE(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \
899*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
900*0e209d39SAndroid Build Coastguard Worker 
901*0e209d39SAndroid Build Coastguard Worker /* definitions with backward iteration -------------------------------------- */
902*0e209d39SAndroid Build Coastguard Worker 
903*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
904*0e209d39SAndroid Build Coastguard Worker #define UTF32_PREV_CHAR_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
905*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[--(i)]; \
906*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
907*0e209d39SAndroid Build Coastguard Worker 
908*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
909*0e209d39SAndroid Build Coastguard Worker #define UTF32_BACK_1_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
910*0e209d39SAndroid Build Coastguard Worker     --(i); \
911*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
912*0e209d39SAndroid Build Coastguard Worker 
913*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
914*0e209d39SAndroid Build Coastguard Worker #define UTF32_BACK_N_UNSAFE(s, i, n) UPRV_BLOCK_MACRO_BEGIN { \
915*0e209d39SAndroid Build Coastguard Worker     (i)-=(n); \
916*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
917*0e209d39SAndroid Build Coastguard Worker 
918*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
919*0e209d39SAndroid Build Coastguard Worker #define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) UPRV_BLOCK_MACRO_BEGIN { \
920*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
921*0e209d39SAndroid Build Coastguard Worker 
922*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
923*0e209d39SAndroid Build Coastguard Worker #define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) UPRV_BLOCK_MACRO_BEGIN { \
924*0e209d39SAndroid Build Coastguard Worker     (c)=(s)[--(i)]; \
925*0e209d39SAndroid Build Coastguard Worker     if(!UTF32_IS_SAFE(c, strict)) { \
926*0e209d39SAndroid Build Coastguard Worker         (c)=UTF_ERROR_VALUE; \
927*0e209d39SAndroid Build Coastguard Worker     } \
928*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
929*0e209d39SAndroid Build Coastguard Worker 
930*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
931*0e209d39SAndroid Build Coastguard Worker #define UTF32_BACK_1_SAFE(s, start, i) UPRV_BLOCK_MACRO_BEGIN { \
932*0e209d39SAndroid Build Coastguard Worker     --(i); \
933*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
934*0e209d39SAndroid Build Coastguard Worker 
935*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
936*0e209d39SAndroid Build Coastguard Worker #define UTF32_BACK_N_SAFE(s, start, i, n) UPRV_BLOCK_MACRO_BEGIN { \
937*0e209d39SAndroid Build Coastguard Worker     (i)-=(n); \
938*0e209d39SAndroid Build Coastguard Worker     if((i)<(start)) { \
939*0e209d39SAndroid Build Coastguard Worker         (i)=(start); \
940*0e209d39SAndroid Build Coastguard Worker     } \
941*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
942*0e209d39SAndroid Build Coastguard Worker 
943*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
944*0e209d39SAndroid Build Coastguard Worker #define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) UPRV_BLOCK_MACRO_BEGIN { \
945*0e209d39SAndroid Build Coastguard Worker } UPRV_BLOCK_MACRO_END
946*0e209d39SAndroid Build Coastguard Worker 
947*0e209d39SAndroid Build Coastguard Worker /* Formerly utf.h, part 2 --------------------------------------------------- */
948*0e209d39SAndroid Build Coastguard Worker 
949*0e209d39SAndroid Build Coastguard Worker /**
950*0e209d39SAndroid Build Coastguard Worker  * Estimate the number of code units for a string based on the number of UTF-16 code units.
951*0e209d39SAndroid Build Coastguard Worker  *
952*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Obsolete, see utf_old.h.
953*0e209d39SAndroid Build Coastguard Worker  */
954*0e209d39SAndroid Build Coastguard Worker #define UTF_ARRAY_SIZE(size) UTF16_ARRAY_SIZE(size)
955*0e209d39SAndroid Build Coastguard Worker 
956*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */
957*0e209d39SAndroid Build Coastguard Worker #define UTF_GET_CHAR_UNSAFE(s, i, c)                 UTF16_GET_CHAR_UNSAFE(s, i, c)
958*0e209d39SAndroid Build Coastguard Worker 
959*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */
960*0e209d39SAndroid Build Coastguard Worker #define UTF_GET_CHAR_SAFE(s, start, i, length, c, strict) UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict)
961*0e209d39SAndroid Build Coastguard Worker 
962*0e209d39SAndroid Build Coastguard Worker 
963*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */
964*0e209d39SAndroid Build Coastguard Worker #define UTF_NEXT_CHAR_UNSAFE(s, i, c)                UTF16_NEXT_CHAR_UNSAFE(s, i, c)
965*0e209d39SAndroid Build Coastguard Worker 
966*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */
967*0e209d39SAndroid Build Coastguard Worker #define UTF_NEXT_CHAR_SAFE(s, i, length, c, strict)  UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict)
968*0e209d39SAndroid Build Coastguard Worker 
969*0e209d39SAndroid Build Coastguard Worker 
970*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */
971*0e209d39SAndroid Build Coastguard Worker #define UTF_APPEND_CHAR_UNSAFE(s, i, c)              UTF16_APPEND_CHAR_UNSAFE(s, i, c)
972*0e209d39SAndroid Build Coastguard Worker 
973*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */
974*0e209d39SAndroid Build Coastguard Worker #define UTF_APPEND_CHAR_SAFE(s, i, length, c)        UTF16_APPEND_CHAR_SAFE(s, i, length, c)
975*0e209d39SAndroid Build Coastguard Worker 
976*0e209d39SAndroid Build Coastguard Worker 
977*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */
978*0e209d39SAndroid Build Coastguard Worker #define UTF_FWD_1_UNSAFE(s, i)                       UTF16_FWD_1_UNSAFE(s, i)
979*0e209d39SAndroid Build Coastguard Worker 
980*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */
981*0e209d39SAndroid Build Coastguard Worker #define UTF_FWD_1_SAFE(s, i, length)                 UTF16_FWD_1_SAFE(s, i, length)
982*0e209d39SAndroid Build Coastguard Worker 
983*0e209d39SAndroid Build Coastguard Worker 
984*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */
985*0e209d39SAndroid Build Coastguard Worker #define UTF_FWD_N_UNSAFE(s, i, n)                    UTF16_FWD_N_UNSAFE(s, i, n)
986*0e209d39SAndroid Build Coastguard Worker 
987*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */
988*0e209d39SAndroid Build Coastguard Worker #define UTF_FWD_N_SAFE(s, i, length, n)              UTF16_FWD_N_SAFE(s, i, length, n)
989*0e209d39SAndroid Build Coastguard Worker 
990*0e209d39SAndroid Build Coastguard Worker 
991*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */
992*0e209d39SAndroid Build Coastguard Worker #define UTF_SET_CHAR_START_UNSAFE(s, i)              UTF16_SET_CHAR_START_UNSAFE(s, i)
993*0e209d39SAndroid Build Coastguard Worker 
994*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */
995*0e209d39SAndroid Build Coastguard Worker #define UTF_SET_CHAR_START_SAFE(s, start, i)         UTF16_SET_CHAR_START_SAFE(s, start, i)
996*0e209d39SAndroid Build Coastguard Worker 
997*0e209d39SAndroid Build Coastguard Worker 
998*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */
999*0e209d39SAndroid Build Coastguard Worker #define UTF_PREV_CHAR_UNSAFE(s, i, c)                UTF16_PREV_CHAR_UNSAFE(s, i, c)
1000*0e209d39SAndroid Build Coastguard Worker 
1001*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */
1002*0e209d39SAndroid Build Coastguard Worker #define UTF_PREV_CHAR_SAFE(s, start, i, c, strict)   UTF16_PREV_CHAR_SAFE(s, start, i, c, strict)
1003*0e209d39SAndroid Build Coastguard Worker 
1004*0e209d39SAndroid Build Coastguard Worker 
1005*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */
1006*0e209d39SAndroid Build Coastguard Worker #define UTF_BACK_1_UNSAFE(s, i)                      UTF16_BACK_1_UNSAFE(s, i)
1007*0e209d39SAndroid Build Coastguard Worker 
1008*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */
1009*0e209d39SAndroid Build Coastguard Worker #define UTF_BACK_1_SAFE(s, start, i)                 UTF16_BACK_1_SAFE(s, start, i)
1010*0e209d39SAndroid Build Coastguard Worker 
1011*0e209d39SAndroid Build Coastguard Worker 
1012*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */
1013*0e209d39SAndroid Build Coastguard Worker #define UTF_BACK_N_UNSAFE(s, i, n)                   UTF16_BACK_N_UNSAFE(s, i, n)
1014*0e209d39SAndroid Build Coastguard Worker 
1015*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */
1016*0e209d39SAndroid Build Coastguard Worker #define UTF_BACK_N_SAFE(s, start, i, n)              UTF16_BACK_N_SAFE(s, start, i, n)
1017*0e209d39SAndroid Build Coastguard Worker 
1018*0e209d39SAndroid Build Coastguard Worker 
1019*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
1020*0e209d39SAndroid Build Coastguard Worker #define UTF_SET_CHAR_LIMIT_UNSAFE(s, i)              UTF16_SET_CHAR_LIMIT_UNSAFE(s, i)
1021*0e209d39SAndroid Build Coastguard Worker 
1022*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */
1023*0e209d39SAndroid Build Coastguard Worker #define UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length) UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length)
1024*0e209d39SAndroid Build Coastguard Worker 
1025*0e209d39SAndroid Build Coastguard Worker /* Define default macros (UTF-16 "safe") ------------------------------------ */
1026*0e209d39SAndroid Build Coastguard Worker 
1027*0e209d39SAndroid Build Coastguard Worker /**
1028*0e209d39SAndroid Build Coastguard Worker  * Does this code unit alone encode a code point (BMP, not a surrogate)?
1029*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_IS_SINGLE.
1030*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U_IS_SINGLE and U16_IS_SINGLE, see utf_old.h.
1031*0e209d39SAndroid Build Coastguard Worker  */
1032*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_SINGLE(uchar) U16_IS_SINGLE(uchar)
1033*0e209d39SAndroid Build Coastguard Worker 
1034*0e209d39SAndroid Build Coastguard Worker /**
1035*0e209d39SAndroid Build Coastguard Worker  * Is this code unit the first one of several (a lead surrogate)?
1036*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_IS_LEAD.
1037*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h.
1038*0e209d39SAndroid Build Coastguard Worker  */
1039*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_LEAD(uchar) U16_IS_LEAD(uchar)
1040*0e209d39SAndroid Build Coastguard Worker 
1041*0e209d39SAndroid Build Coastguard Worker /**
1042*0e209d39SAndroid Build Coastguard Worker  * Is this code unit one of several but not the first one (a trail surrogate)?
1043*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_IS_TRAIL.
1044*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h.
1045*0e209d39SAndroid Build Coastguard Worker  */
1046*0e209d39SAndroid Build Coastguard Worker #define UTF_IS_TRAIL(uchar) U16_IS_TRAIL(uchar)
1047*0e209d39SAndroid Build Coastguard Worker 
1048*0e209d39SAndroid Build Coastguard Worker /**
1049*0e209d39SAndroid Build Coastguard Worker  * Does this code point require multiple code units (is it a supplementary code point)?
1050*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_NEED_MULTIPLE_UCHAR.
1051*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead.
1052*0e209d39SAndroid Build Coastguard Worker  */
1053*0e209d39SAndroid Build Coastguard Worker #define UTF_NEED_MULTIPLE_UCHAR(c) UTF16_NEED_MULTIPLE_UCHAR(c)
1054*0e209d39SAndroid Build Coastguard Worker 
1055*0e209d39SAndroid Build Coastguard Worker /**
1056*0e209d39SAndroid Build Coastguard Worker  * How many code units are used to encode this code point (1 or 2)?
1057*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_CHAR_LENGTH.
1058*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h.
1059*0e209d39SAndroid Build Coastguard Worker  */
1060*0e209d39SAndroid Build Coastguard Worker #define UTF_CHAR_LENGTH(c) U16_LENGTH(c)
1061*0e209d39SAndroid Build Coastguard Worker 
1062*0e209d39SAndroid Build Coastguard Worker /**
1063*0e209d39SAndroid Build Coastguard Worker  * How many code units are used at most for any Unicode code point (2)?
1064*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_MAX_CHAR_LENGTH.
1065*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h.
1066*0e209d39SAndroid Build Coastguard Worker  */
1067*0e209d39SAndroid Build Coastguard Worker #define UTF_MAX_CHAR_LENGTH U16_MAX_LENGTH
1068*0e209d39SAndroid Build Coastguard Worker 
1069*0e209d39SAndroid Build Coastguard Worker /**
1070*0e209d39SAndroid Build Coastguard Worker  * Set c to the code point that contains the code unit i.
1071*0e209d39SAndroid Build Coastguard Worker  * i could point to the lead or the trail surrogate for the code point.
1072*0e209d39SAndroid Build Coastguard Worker  * i is not modified.
1073*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_GET_CHAR.
1074*0e209d39SAndroid Build Coastguard Worker  * \pre 0<=i<length
1075*0e209d39SAndroid Build Coastguard Worker  *
1076*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_GET, see utf_old.h.
1077*0e209d39SAndroid Build Coastguard Worker  */
1078*0e209d39SAndroid Build Coastguard Worker #define UTF_GET_CHAR(s, start, i, length, c) U16_GET(s, start, i, length, c)
1079*0e209d39SAndroid Build Coastguard Worker 
1080*0e209d39SAndroid Build Coastguard Worker /**
1081*0e209d39SAndroid Build Coastguard Worker  * Set c to the code point that starts at code unit i
1082*0e209d39SAndroid Build Coastguard Worker  * and advance i to beyond the code units of this code point (post-increment).
1083*0e209d39SAndroid Build Coastguard Worker  * i must point to the first code unit of a code point.
1084*0e209d39SAndroid Build Coastguard Worker  * Otherwise c is set to the trail unit (surrogate) itself.
1085*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_NEXT_CHAR.
1086*0e209d39SAndroid Build Coastguard Worker  * \pre 0<=i<length
1087*0e209d39SAndroid Build Coastguard Worker  * \post 0<i<=length
1088*0e209d39SAndroid Build Coastguard Worker  *
1089*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_NEXT, see utf_old.h.
1090*0e209d39SAndroid Build Coastguard Worker  */
1091*0e209d39SAndroid Build Coastguard Worker #define UTF_NEXT_CHAR(s, i, length, c) U16_NEXT(s, i, length, c)
1092*0e209d39SAndroid Build Coastguard Worker 
1093*0e209d39SAndroid Build Coastguard Worker /**
1094*0e209d39SAndroid Build Coastguard Worker  * Append the code units of code point c to the string at index i
1095*0e209d39SAndroid Build Coastguard Worker  * and advance i to beyond the new code units (post-increment).
1096*0e209d39SAndroid Build Coastguard Worker  * The code units beginning at index i will be overwritten.
1097*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_APPEND_CHAR.
1098*0e209d39SAndroid Build Coastguard Worker  * \pre 0<=c<=0x10ffff
1099*0e209d39SAndroid Build Coastguard Worker  * \pre 0<=i<length
1100*0e209d39SAndroid Build Coastguard Worker  * \post 0<i<=length
1101*0e209d39SAndroid Build Coastguard Worker  *
1102*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h.
1103*0e209d39SAndroid Build Coastguard Worker  */
1104*0e209d39SAndroid Build Coastguard Worker #define UTF_APPEND_CHAR(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c)
1105*0e209d39SAndroid Build Coastguard Worker 
1106*0e209d39SAndroid Build Coastguard Worker /**
1107*0e209d39SAndroid Build Coastguard Worker  * Advance i to beyond the code units of the code point that begins at i.
1108*0e209d39SAndroid Build Coastguard Worker  * I.e., advance i by one code point.
1109*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_FWD_1.
1110*0e209d39SAndroid Build Coastguard Worker  * \pre 0<=i<length
1111*0e209d39SAndroid Build Coastguard Worker  * \post 0<i<=length
1112*0e209d39SAndroid Build Coastguard Worker  *
1113*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h.
1114*0e209d39SAndroid Build Coastguard Worker  */
1115*0e209d39SAndroid Build Coastguard Worker #define UTF_FWD_1(s, i, length) U16_FWD_1(s, i, length)
1116*0e209d39SAndroid Build Coastguard Worker 
1117*0e209d39SAndroid Build Coastguard Worker /**
1118*0e209d39SAndroid Build Coastguard Worker  * Advance i to beyond the code units of the n code points where the first one begins at i.
1119*0e209d39SAndroid Build Coastguard Worker  * I.e., advance i by n code points.
1120*0e209d39SAndroid Build Coastguard Worker  * Same as UT16_FWD_N.
1121*0e209d39SAndroid Build Coastguard Worker  * \pre 0<=i<length
1122*0e209d39SAndroid Build Coastguard Worker  * \post 0<i<=length
1123*0e209d39SAndroid Build Coastguard Worker  *
1124*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h.
1125*0e209d39SAndroid Build Coastguard Worker  */
1126*0e209d39SAndroid Build Coastguard Worker #define UTF_FWD_N(s, i, length, n) U16_FWD_N(s, i, length, n)
1127*0e209d39SAndroid Build Coastguard Worker 
1128*0e209d39SAndroid Build Coastguard Worker /**
1129*0e209d39SAndroid Build Coastguard Worker  * Take the random-access index i and adjust it so that it points to the beginning
1130*0e209d39SAndroid Build Coastguard Worker  * of a code point.
1131*0e209d39SAndroid Build Coastguard Worker  * The input index points to any code unit of a code point and is moved to point to
1132*0e209d39SAndroid Build Coastguard Worker  * the first code unit of the same code point. i is never incremented.
1133*0e209d39SAndroid Build Coastguard Worker  * In other words, if i points to a trail surrogate that is preceded by a matching
1134*0e209d39SAndroid Build Coastguard Worker  * lead surrogate, then i is decremented. Otherwise it is not modified.
1135*0e209d39SAndroid Build Coastguard Worker  * This can be used to start an iteration with UTF_NEXT_CHAR() from a random index.
1136*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_SET_CHAR_START.
1137*0e209d39SAndroid Build Coastguard Worker  * \pre start<=i<length
1138*0e209d39SAndroid Build Coastguard Worker  * \post start<=i<length
1139*0e209d39SAndroid Build Coastguard Worker  *
1140*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h.
1141*0e209d39SAndroid Build Coastguard Worker  */
1142*0e209d39SAndroid Build Coastguard Worker #define UTF_SET_CHAR_START(s, start, i) U16_SET_CP_START(s, start, i)
1143*0e209d39SAndroid Build Coastguard Worker 
1144*0e209d39SAndroid Build Coastguard Worker /**
1145*0e209d39SAndroid Build Coastguard Worker  * Set c to the code point that has code units before i
1146*0e209d39SAndroid Build Coastguard Worker  * and move i backward (towards the beginning of the string)
1147*0e209d39SAndroid Build Coastguard Worker  * to the first code unit of this code point (pre-increment).
1148*0e209d39SAndroid Build Coastguard Worker  * i must point to the first code unit after the last unit of a code point (i==length is allowed).
1149*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_PREV_CHAR.
1150*0e209d39SAndroid Build Coastguard Worker  * \pre start<i<=length
1151*0e209d39SAndroid Build Coastguard Worker  * \post start<=i<length
1152*0e209d39SAndroid Build Coastguard Worker  *
1153*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_PREV, see utf_old.h.
1154*0e209d39SAndroid Build Coastguard Worker  */
1155*0e209d39SAndroid Build Coastguard Worker #define UTF_PREV_CHAR(s, start, i, c) U16_PREV(s, start, i, c)
1156*0e209d39SAndroid Build Coastguard Worker 
1157*0e209d39SAndroid Build Coastguard Worker /**
1158*0e209d39SAndroid Build Coastguard Worker  * Move i backward (towards the beginning of the string)
1159*0e209d39SAndroid Build Coastguard Worker  * to the first code unit of the code point that has code units before i.
1160*0e209d39SAndroid Build Coastguard Worker  * I.e., move i backward by one code point.
1161*0e209d39SAndroid Build Coastguard Worker  * i must point to the first code unit after the last unit of a code point (i==length is allowed).
1162*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_BACK_1.
1163*0e209d39SAndroid Build Coastguard Worker  * \pre start<i<=length
1164*0e209d39SAndroid Build Coastguard Worker  * \post start<=i<length
1165*0e209d39SAndroid Build Coastguard Worker  *
1166*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h.
1167*0e209d39SAndroid Build Coastguard Worker  */
1168*0e209d39SAndroid Build Coastguard Worker #define UTF_BACK_1(s, start, i) U16_BACK_1(s, start, i)
1169*0e209d39SAndroid Build Coastguard Worker 
1170*0e209d39SAndroid Build Coastguard Worker /**
1171*0e209d39SAndroid Build Coastguard Worker  * Move i backward (towards the beginning of the string)
1172*0e209d39SAndroid Build Coastguard Worker  * to the first code unit of the n code points that have code units before i.
1173*0e209d39SAndroid Build Coastguard Worker  * I.e., move i backward by n code points.
1174*0e209d39SAndroid Build Coastguard Worker  * i must point to the first code unit after the last unit of a code point (i==length is allowed).
1175*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_BACK_N.
1176*0e209d39SAndroid Build Coastguard Worker  * \pre start<i<=length
1177*0e209d39SAndroid Build Coastguard Worker  * \post start<=i<length
1178*0e209d39SAndroid Build Coastguard Worker  *
1179*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h.
1180*0e209d39SAndroid Build Coastguard Worker  */
1181*0e209d39SAndroid Build Coastguard Worker #define UTF_BACK_N(s, start, i, n) U16_BACK_N(s, start, i, n)
1182*0e209d39SAndroid Build Coastguard Worker 
1183*0e209d39SAndroid Build Coastguard Worker /**
1184*0e209d39SAndroid Build Coastguard Worker  * Take the random-access index i and adjust it so that it points beyond
1185*0e209d39SAndroid Build Coastguard Worker  * a code point. The input index points beyond any code unit
1186*0e209d39SAndroid Build Coastguard Worker  * of a code point and is moved to point beyond the last code unit of the same
1187*0e209d39SAndroid Build Coastguard Worker  * code point. i is never decremented.
1188*0e209d39SAndroid Build Coastguard Worker  * In other words, if i points to a trail surrogate that is preceded by a matching
1189*0e209d39SAndroid Build Coastguard Worker  * lead surrogate, then i is incremented. Otherwise it is not modified.
1190*0e209d39SAndroid Build Coastguard Worker  * This can be used to start an iteration with UTF_PREV_CHAR() from a random index.
1191*0e209d39SAndroid Build Coastguard Worker  * Same as UTF16_SET_CHAR_LIMIT.
1192*0e209d39SAndroid Build Coastguard Worker  * \pre start<i<=length
1193*0e209d39SAndroid Build Coastguard Worker  * \post start<i<=length
1194*0e209d39SAndroid Build Coastguard Worker  *
1195*0e209d39SAndroid Build Coastguard Worker  * @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h.
1196*0e209d39SAndroid Build Coastguard Worker  */
1197*0e209d39SAndroid Build Coastguard Worker #define UTF_SET_CHAR_LIMIT(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
1198*0e209d39SAndroid Build Coastguard Worker 
1199*0e209d39SAndroid Build Coastguard Worker #endif  // !U_HIDE_DEPRECATED_API && !U_HIDE_OBSOLETE_UTF_OLD_H
1200*0e209d39SAndroid Build Coastguard Worker 
1201*0e209d39SAndroid Build Coastguard Worker #endif
1202