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