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