16f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/*
26f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*******************************************************************************
36f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
46f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   Copyright (C) 2002-2012, International Business Machines
56f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   Corporation and others.  All Rights Reserved.
66f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
76f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*******************************************************************************
86f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   file name:  utf_old.h
96f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   encoding:   US-ASCII
106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   tab size:   8 (not used)
116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   indentation:4
126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   created on: 2002sep21
146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   created by: Markus W. Scherer
156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*/
166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \file
196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \brief C API: Deprecated macros for Unicode string handling
206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The macros in utf_old.h are all deprecated and their use discouraged.
256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Some of the design principles behind the set of UTF macros
266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * have changed or proved impractical.
276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Almost all of the old "UTF macros" are at least renamed.
286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * If you are looking for a new equivalent to an old macro, please see the
296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * comment at the old one.
306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Brief summary of reasons for deprecation:
326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - Switch on UTF_SIZE (selection of UTF-8/16/32 default string processing)
336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   was impractical.
346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - Switch on UTF_SAFE etc. (selection of unsafe/safe/strict default string processing)
356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   was of little use and impractical.
366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - Whole classes of macros became obsolete outside of the UTF_SIZE/UTF_SAFE
376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   selection framework: UTF32_ macros (all trivial)
386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   and UTF_ default and intermediate macros (all aliases).
396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - The selection framework also caused many macro aliases.
406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - Change in Unicode standard: "irregular" sequences (3.0) became illegal (3.2).
416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - Change of language in Unicode standard:
426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   Growing distinction between internal x-bit Unicode strings and external UTF-x
436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   forms, with the former more lenient.
446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   Suggests renaming of UTF16_ macros to U16_.
456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - The prefix "UTF_" without a width number confused some users.
466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - "Safe" append macros needed the addition of an error indicator output.
476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - "Safe" UTF-8 macros used legitimate (if rarely used) code point values
486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *   to indicate error conditions.
496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - The use of the "_CHAR" infix for code point operations confused some users.
506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * More details:
526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Until ICU 2.2, utf.h theoretically allowed to choose among UTF-8/16/32
546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * for string processing, and among unsafe/safe/strict default macros for that.
556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * It proved nearly impossible to write non-trivial, high-performance code
576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * that is UTF-generic.
586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Unsafe default macros would be dangerous for default string processing,
596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * and the main reason for the "strict" versions disappeared:
606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Between Unicode 3.0 and 3.2 all "irregular" UTF-8 sequences became illegal.
616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The only other conditions that "strict" checked for were non-characters,
626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * which are valid during processing. Only during text input/output should they
636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * be checked, and at that time other well-formedness checks may be
646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * necessary or useful as well.
656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This can still be done by using U16_NEXT and U_IS_UNICODE_NONCHAR
666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * or U_IS_UNICODE_CHAR.
676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The old UTF8_..._SAFE macros also used some normal Unicode code points
696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * to indicate malformed sequences.
706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The new UTF8_ macros without suffix use negative values instead.
716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The entire contents of utf32.h was moved here without replacement
736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * because all those macros were trivial and
746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * were meaningful only in the framework of choosing the UTF size.
756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * See Jitterbug 2150 and its discussion on the ICU mailing list
776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * in September 2002.
786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <hr>
806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <em>Obsolete part</em> of pre-ICU 2.4 utf.h file documentation:
826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>The original concept for these files was for ICU to allow
846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * in principle to set which UTF (UTF-8/16/32) is used internally
856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * by defining UTF_SIZE to either 8, 16, or 32. utf.h would then define the UChar type
866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * accordingly. UTF-16 was the default.</p>
876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>This concept has been abandoned.
896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * A lot of the ICU source code assumes UChar strings are in UTF-16.
906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This is especially true for low-level code like
916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * conversion, normalization, and collation.
926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The utf.h header enforces the default of UTF-16.
936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The UTF-8 and UTF-32 macros remain for now for completeness and backward compatibility.</p>
946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>Accordingly, utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then
966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * UChar is defined to be exactly wchar_t, otherwise uint16_t.</p>
976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit
996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Unicode code point (Unicode scalar value, 0..0x10ffff).
1006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as
1016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * the definition of UChar. For details see the documentation for UChar32 itself.</p>
1026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>utf.h also defines a number of C macros for handling single Unicode code points and
1046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * for using UTF Unicode strings. It includes utf8.h, utf16.h, and utf32.h for the actual
1056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * implementations of those macros and then aliases one set of them (for UTF-16) for general use.
1066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The UTF-specific macros have the UTF size in the macro name prefixes (UTF16_...), while
1076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * the general alias macros always begin with UTF_...</p>
1086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>Many string operations can be done with or without error checking.
1106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Where such a distinction is useful, there are two versions of the macros, "unsafe" and "safe"
1116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause
1126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * program failures if the strings are not well-formed. The safe macros have an additional, boolean
1136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * parameter "strict". If strict is FALSE, then only illegal sequences are detected.
1146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Otherwise, irregular sequences and non-characters are detected as well (like single surrogates).
1156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Safe macros return special error code points for illegal/irregular sequences:
1166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Typically, U+ffff, or values that would result in a code unit sequence of the same length
1176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * as the erroneous input sequence.<br>
1186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Note that _UNSAFE macros have fewer parameters: They do not have the strictness parameter, and
1196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * they do not have start/length parameters for boundary checking.</p>
1206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>Here, the macros are aliased in two steps:
1226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * In the first step, the UTF-specific macros with UTF16_ prefix and _UNSAFE and _SAFE suffixes are
1236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * aliased according to the UTF_SIZE to macros with UTF_ prefix and the same suffixes and signatures.
1246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Then, in a second step, the default, general alias macros are set to use either the unsafe or
1256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * the safe/not strict (default) or the safe/strict macro;
1266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * these general macros do not have a strictness parameter.</p>
1276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>It is possible to change the default choice for the general alias macros to be unsafe, safe/not strict or safe/strict.
1296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The default is safe/not strict. It is not recommended to select the unsafe macros as the basis for
1306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Unicode string handling in ICU! To select this, define UTF_SAFE, UTF_STRICT, or UTF_UNSAFE.</p>
1316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <p>For general use, one should use the default, general macros with UTF_ prefix and no _SAFE/_UNSAFE suffix.
1336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Only in some cases it may be necessary to control the choice of macro directly and use a less generic alias.
1346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * For example, if it can be assumed that a string is well-formed and the index will stay within the bounds,
1356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * then the _UNSAFE version may be used.
1366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * If a UTF-8 string is to be processed, then the macros with UTF8_ prefixes need to be used.</p>
1376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * <hr>
1396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead.
1416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
1426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef __UTF_OLD_H__
1446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define __UTF_OLD_H__
1456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef U_HIDE_DEPRECATED_API
1476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/utf.h"
1496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/utf8.h"
1506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/utf16.h"
1516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Formerly utf.h, part 1 --------------------------------------------------- */
1536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifdef U_USE_UTF_DEPRECATES
1556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
1566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Unicode string and array offset and index type.
1576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * ICU always counts Unicode code units (UChars) for
1586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * string offsets, indexes, and lengths, not Unicode code points.
1596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @obsolete ICU 2.6. Use int32_t directly instead since this API will be removed in that release.
1616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
1626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgtypedef int32_t UTextOffset;
1636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
1646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Number of bits in a Unicode string code unit - ICU uses 16-bit Unicode. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
1666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SIZE 16
1676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
1696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The default choice for general Unicode string macros is to use the ..._SAFE macro implementations
1706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * with strict=FALSE.
1716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
1736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
1746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SAFE
1756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
1766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#undef UTF_UNSAFE
1776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
1786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#undef UTF_STRICT
1796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
1816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8,
1826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * which need 1 or 2 bytes in UTF-8:
1836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \code
1846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * U+0015 = NAK = Negative Acknowledge, C0 control character
1856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * U+009f = highest C1 control character
1866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \endcode
1876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * These are used by UTF8_..._SAFE macros so that they can return an error value
1896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * that needs the same number of code units (bytes) as were seen by
1906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * a macro. They should be tested with UTF_IS_ERROR() or UTF_IS_VALID().
1916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
1936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
1946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_ERROR_VALUE_1 0x15
1956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
1976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * See documentation on UTF8_ERROR_VALUE_1 for details.
1986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
1996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
2006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_ERROR_VALUE_2 0x9f
2026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Error value for all UTFs. This code point value will be set by macros with error
2056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * checking if an error is detected.
2066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
2086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_ERROR_VALUE 0xffff
2106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Is a given 32-bit code an error value
2136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * as returned by one of the macros for any UTF?
2146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
2166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_ERROR(c) \
2186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (((c)&0xfffe)==0xfffe || (c)==UTF8_ERROR_VALUE_1 || (c)==UTF8_ERROR_VALUE_2)
2196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This is a combined macro: Is c a valid Unicode value _and_ not an error code?
2226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
2246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_VALID(c) \
2266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (UTF_IS_UNICODE_CHAR(c) && \
2276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     (c)!=UTF8_ERROR_VALUE_1 && (c)!=UTF8_ERROR_VALUE_2)
2286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Is this code unit or code point a surrogate (U+d800..U+dfff)?
2316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U_IS_SURROGATE and U16_IS_SURROGATE, see utf_old.h.
2326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_SURROGATE(uchar) (((uchar)&0xfffff800)==0xd800)
2346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Is a given 32-bit code point a Unicode noncharacter?
2376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_NONCHAR, see utf_old.h.
2396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_UNICODE_NONCHAR(c) \
2416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    ((c)>=0xfdd0 && \
2426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \
2436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     (uint32_t)(c)<=0x10ffff)
2446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Is a given 32-bit value a Unicode code point value (0..U+10ffff)
2476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * that can be assigned a character?
2486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Code points that are not characters include:
2506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - single surrogate code points (U+d800..U+dfff, 2048 code points)
2516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
2526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
2536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * - the highest Unicode code point value is U+10ffff
2546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This means that all code points below U+d800 are character code points,
2566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * and that boundary is tested first for performance.
2576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_CHAR, see utf_old.h.
2596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_UNICODE_CHAR(c) \
2616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    ((uint32_t)(c)<0xd800 || \
2626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        ((uint32_t)(c)>0xdfff && \
2636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         (uint32_t)(c)<=0x10ffff && \
2646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         !UTF_IS_UNICODE_NONCHAR(c)))
2656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Formerly utf8.h ---------------------------------------------------------- */
2676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Count the trail bytes for a UTF-8 lead byte.
2706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U8_COUNT_TRAIL_BYTES, see utf_old.h.
2716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])
2736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.
2766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U8_MASK_LEAD_BYTE, see utf_old.h.
2776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
2786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)
2796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Is this this code point a single code unit (byte)? @deprecated ICU 2.4. Renamed to U8_IS_SINGLE, see utf_old.h. */
2816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_IS_SINGLE(uchar) (((uchar)&0x80)==0)
2826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** 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. */
2836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_IS_LEAD(uchar) ((uint8_t)((uchar)-0xc0)<0x3e)
2846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** 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. */
2856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_IS_TRAIL(uchar) (((uchar)&0xc0)==0x80)
2866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** 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. */
2886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0x7f)
2896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
2916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Given the lead character, how many bytes are taken by this code point.
2926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * ICU does not deal with code points >0x10ffff
2936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * unless necessary for advancing in the byte stream.
2946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
2956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * These length macros take into account that for values >0x10ffff
2966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * the UTF8_APPEND_CHAR_SAFE macros would write the error code point 0xffff
2976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * with 3 bytes.
2986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Code point comparisons need to be in uint32_t because UChar32
2996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * may be a signed type, and negative values must be recognized.
3006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
3016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Use U8_LENGTH instead, see utf.h.
3026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
3036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if 1
3046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#   define UTF8_CHAR_LENGTH(c) \
3056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        ((uint32_t)(c)<=0x7f ? 1 : \
3066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ((uint32_t)(c)<=0x7ff ? 2 : \
3076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                ((uint32_t)((c)-0x10000)>0xfffff ? 3 : 4) \
3086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ) \
3096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        )
3106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#else
3116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#   define UTF8_CHAR_LENGTH(c) \
3126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        ((uint32_t)(c)<=0x7f ? 1 : \
3136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ((uint32_t)(c)<=0x7ff ? 2 : \
3146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                ((uint32_t)(c)<=0xffff ? 3 : \
3156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    ((uint32_t)(c)<=0x10ffff ? 4 : \
3166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                        ((uint32_t)(c)<=0x3ffffff ? 5 : \
3176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                            ((uint32_t)(c)<=0x7fffffff ? 6 : 3) \
3186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                        ) \
3196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                    ) \
3206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                ) \
3216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ) \
3226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        )
3236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
3246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** The maximum number of bytes per code point. @deprecated ICU 2.4. Renamed to U8_MAX_LENGTH, see utf_old.h. */
3266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_MAX_CHAR_LENGTH 4
3276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
3296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_ARRAY_SIZE(size) ((5*(size))/2)
3306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */
3326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_GET_CHAR_UNSAFE(s, i, c) { \
3336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \
3346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \
3356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \
3366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
3376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */
3396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
3406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t _utf8_get_char_safe_index=(int32_t)(i); \
3416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \
3426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \
3436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
3446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */
3466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) { \
3476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[(i)++]; \
3486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((uint8_t)((c)-0xc0)<0x35) { \
3496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \
3506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        UTF8_MASK_LEAD_BYTE(c, __count); \
3516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        switch(__count) { \
3526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        /* each following branch falls through to the next one */ \
3536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        case 3: \
3546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
3556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        case 2: \
3566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
3576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        case 1: \
3586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
3596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        /* no other branches to optimize switch() */ \
3606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            break; \
3616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
3626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
3636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
3646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */
3666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) { \
3676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((uint32_t)(c)<=0x7f) { \
3686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint8_t)(c); \
3696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else { \
3706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if((uint32_t)(c)<=0x7ff) { \
3716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \
3726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else { \
3736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            if((uint32_t)(c)<=0xffff) { \
3746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \
3756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } else { \
3766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \
3776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \
3786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } \
3796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \
3806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
3816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
3826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
3836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
3846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */
3866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_FWD_1_UNSAFE(s, i) { \
3876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \
3886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
3896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */
3916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_FWD_N_UNSAFE(s, i, n) { \
3926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t __N=(n); \
3936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    while(__N>0) { \
3946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        UTF8_FWD_1_UNSAFE(s, i); \
3956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        --__N; \
3966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
3976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
3986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */
4006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_SET_CHAR_START_UNSAFE(s, i) { \
4016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    while(UTF8_IS_TRAIL((s)[i])) { --(i); } \
4026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */
4056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
4066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[(i)++]; \
4076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((c)>=0x80) { \
4086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if(UTF8_IS_LEAD(c)) { \
4096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=utf8_nextCharSafeBody(s, &(i), (int32_t)(length), c, strict); \
4106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else { \
4116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF8_ERROR_VALUE_1; \
4126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
4136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
4146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */
4176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_APPEND_CHAR_SAFE(s, i, length, c)  { \
4186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((uint32_t)(c)<=0x7f) { \
4196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint8_t)(c); \
4206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else { \
4216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \
4226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
4236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */
4266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length)
4276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_FWD_N, see utf_old.h. */
4296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_FWD_N_SAFE(s, i, length, n) U8_FWD_N(s, i, length, n)
4306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_SET_CP_START, see utf_old.h. */
4326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i)
4336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */
4356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_PREV_CHAR_UNSAFE(s, i, c) { \
4366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[--(i)]; \
4376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF8_IS_TRAIL(c)) { \
4386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        uint8_t __b, __count=1, __shift=6; \
4396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org\
4406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        /* c is a trail byte */ \
4416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)&=0x3f; \
4426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        for(;;) { \
4436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            __b=(s)[--(i)]; \
4446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            if(__b>=0xc0) { \
4456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                UTF8_MASK_LEAD_BYTE(__b, __count); \
4466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (c)|=(UChar32)__b<<__shift; \
4476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                break; \
4486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } else { \
4496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (c)|=(UChar32)(__b&0x3f)<<__shift; \
4506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                ++__count; \
4516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                __shift+=6; \
4526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } \
4536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
4546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
4556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */
4586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_BACK_1_UNSAFE(s, i) { \
4596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    while(UTF8_IS_TRAIL((s)[--(i)])) {} \
4606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */
4636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_BACK_N_UNSAFE(s, i, n) { \
4646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t __N=(n); \
4656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    while(__N>0) { \
4666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        UTF8_BACK_1_UNSAFE(s, i); \
4676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        --__N; \
4686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
4696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
4726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) { \
4736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTF8_BACK_1_UNSAFE(s, i); \
4746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTF8_FWD_1_UNSAFE(s, i); \
4756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */
4786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) { \
4796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[--(i)]; \
4806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((c)>=0x80) { \
4816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if((c)<=0xbf) { \
4826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=utf8_prevCharSafeBody(s, start, &(i), c, strict); \
4836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else { \
4846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF8_ERROR_VALUE_1; \
4856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
4866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
4876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
4886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */
4906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i)
4916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_BACK_N, see utf_old.h. */
4936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_BACK_N_SAFE(s, start, i, n) U8_BACK_N(s, start, i, n)
4946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT, see utf_old.h. */
4966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF8_SET_CHAR_LIMIT_SAFE(s, start, i, length) U8_SET_CP_LIMIT(s, start, i, length)
4976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Formerly utf16.h --------------------------------------------------------- */
4996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Is uchar a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h. */
5016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_FIRST_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xd800)
5026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Is uchar a second/trail surrogate? @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h. */
5046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_SECOND_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xdc00)
5056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** 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. */
5076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_SURROGATE_FIRST(c) (((c)&0x400)==0)
5086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Helper constant for UTF16_GET_PAIR_VALUE. @deprecated ICU 2.4. Renamed to U16_SURROGATE_OFFSET, see utf_old.h. */
5106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
5116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Get the UTF-32 value from the surrogate code units. @deprecated ICU 2.4. Renamed to U16_GET_SUPPLEMENTARY, see utf_old.h. */
5136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_GET_PAIR_VALUE(first, second) \
5146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (((first)<<10UL)+(second)-UTF_SURROGATE_OFFSET)
5156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */
5176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FIRST_SURROGATE(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)
5186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */
5206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SECOND_SURROGATE(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)
5216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */
5236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_LEAD(supplementary) UTF_FIRST_SURROGATE(supplementary)
5246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */
5266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_TRAIL(supplementary) UTF_SECOND_SURROGATE(supplementary)
5276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_IS_SINGLE, see utf_old.h. */
5296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_IS_SINGLE(uchar) !UTF_IS_SURROGATE(uchar)
5306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_IS_LEAD, see utf_old.h. */
5326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_IS_LEAD(uchar) UTF_IS_FIRST_SURROGATE(uchar)
5336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_IS_TRAIL, see utf_old.h. */
5356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_IS_TRAIL(uchar) UTF_IS_SECOND_SURROGATE(uchar)
5366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** 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. */
5386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0xffff)
5396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h. */
5416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_CHAR_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
5426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h. */
5446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_MAX_CHAR_LENGTH 2
5456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
5476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_ARRAY_SIZE(size) (size)
5486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
5506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Get a single code point from an offset that points to any
5516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * of the code units that belong to that code point.
5526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Assume 0<=i<length.
5536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
5546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This could be used for iteration together with
5556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * UTF16_CHAR_LENGTH() and UTF_IS_ERROR(),
5566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * but the use of UTF16_NEXT_CHAR[_UNSAFE]() and
5576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that.
5586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h.
5596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
5606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_GET_CHAR_UNSAFE(s, i, c) { \
5616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[i]; \
5626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_SURROGATE(c)) { \
5636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if(UTF_IS_SURROGATE_FIRST(c)) { \
5646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)+1]); \
5656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else { \
5666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \
5676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
5686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
5696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
5706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */
5726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
5736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[i]; \
5746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_SURROGATE(c)) { \
5756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        uint16_t __c2; \
5766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if(UTF_IS_SURROGATE_FIRST(c)) { \
5776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            if((i)+1<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)+1])) { \
5786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (c)=UTF16_GET_PAIR_VALUE((c), __c2); \
5796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
5806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } else if(strict) {\
5816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                /* unmatched first surrogate */ \
5826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (c)=UTF_ERROR_VALUE; \
5836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } \
5846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else { \
5856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            if((i)-1>=(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
5866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
5876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
5886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } else if(strict) {\
5896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                /* unmatched second surrogate */ \
5906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                (c)=UTF_ERROR_VALUE; \
5916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } \
5926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
5936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
5946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF_ERROR_VALUE; \
5956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
5966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
5976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */
5996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) { \
6006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[(i)++]; \
6016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_FIRST_SURROGATE(c)) { \
6026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \
6036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */
6076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) { \
6086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((uint32_t)(c)<=0xffff) { \
6096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint16_t)(c); \
6106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else { \
6116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
6126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
6136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */
6176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_FWD_1_UNSAFE(s, i) { \
6186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \
6196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        ++(i); \
6206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */
6246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_FWD_N_UNSAFE(s, i, n) { \
6256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t __N=(n); \
6266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    while(__N>0) { \
6276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        UTF16_FWD_1_UNSAFE(s, i); \
6286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        --__N; \
6296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */
6336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_SET_CHAR_START_UNSAFE(s, i) { \
6346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_SECOND_SURROGATE((s)[i])) { \
6356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        --(i); \
6366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */
6406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
6416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[(i)++]; \
6426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_FIRST_SURROGATE(c)) { \
6436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        uint16_t __c2; \
6446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if((i)<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)])) { \
6456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            ++(i); \
6466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF16_GET_PAIR_VALUE((c), __c2); \
6476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
6486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else if(strict) {\
6496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            /* unmatched first surrogate */ \
6506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF_ERROR_VALUE; \
6516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
6526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
6536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        /* unmatched second surrogate or other non-character */ \
6546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF_ERROR_VALUE; \
6556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */
6596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) { \
6606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((uint32_t)(c)<=0xffff) { \
6616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(uint16_t)(c); \
6626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else if((uint32_t)(c)<=0x10ffff) { \
6636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if((i)+1<(length)) { \
6646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
6656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
6666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else /* not enough space */ { \
6676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (s)[(i)++]=UTF_ERROR_VALUE; \
6686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
6696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else /* c>0x10ffff, write error value */ { \
6706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=UTF_ERROR_VALUE; \
6716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */
6756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length)
6766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */
6786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_FWD_N_SAFE(s, i, length, n) U16_FWD_N(s, i, length, n)
6796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */
6816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i)
6826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */
6846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_PREV_CHAR_UNSAFE(s, i, c) { \
6856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[--(i)]; \
6866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_SECOND_SURROGATE(c)) { \
6876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \
6886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */
6926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_BACK_1_UNSAFE(s, i) { \
6936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \
6946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        --(i); \
6956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
6966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
6976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */
6996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_BACK_N_UNSAFE(s, i, n) { \
7006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t __N=(n); \
7016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    while(__N>0) { \
7026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        UTF16_BACK_1_UNSAFE(s, i); \
7036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        --__N; \
7046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
7056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
7066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
7086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) { \
7096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \
7106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        ++(i); \
7116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
7126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
7136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */
7156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \
7166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[--(i)]; \
7176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(UTF_IS_SECOND_SURROGATE(c)) { \
7186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        uint16_t __c2; \
7196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        if((i)>(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
7206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            --(i); \
7216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
7226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
7236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } else if(strict) {\
7246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            /* unmatched second surrogate */ \
7256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            (c)=UTF_ERROR_VALUE; \
7266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        } \
7276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
7286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        /* unmatched first surrogate or other non-character */ \
7296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF_ERROR_VALUE; \
7306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
7316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
7326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */
7346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i)
7356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */
7376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_BACK_N_SAFE(s, start, i, n) U16_BACK_N(s, start, i, n)
7386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */
7406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
7416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Formerly utf32.h --------------------------------------------------------- */
7436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/*
7456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org* Old documentation:
7466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*
7476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   This file defines macros to deal with UTF-32 code units and code points.
7486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   Signatures and semantics are the same as for the similarly named macros
7496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   in utf16.h.
7506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   utf32.h is included by utf.h after unicode/umachine.h</p>
7516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   and some common definitions.
7526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*   <p><b>Usage:</b>  ICU coding guidelines for if() statements should be followed when using these macros.
7536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*                  Compound statements (curly braces {}) must be used  for if-else-while...
7546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*                  bodies and all macro statements should be terminated with semicolon.</p>
7556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org*/
7566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* internal definitions ----------------------------------------------------- */
7586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_IS_SAFE(c, strict) \
7616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (!(strict) ? \
7626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (uint32_t)(c)<=0x10ffff : \
7636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        UTF_IS_UNICODE_CHAR(c))
7646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/*
7666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * For the semantics of all of these macros, see utf16.h.
7676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The UTF-32 versions are trivial because any code point is
7686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * encoded using exactly one code unit.
7696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
7706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* single-code point definitions -------------------------------------------- */
7726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* classes of code unit values */
7746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_IS_SINGLE(uchar) 1
7776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_IS_LEAD(uchar) 0
7796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_IS_TRAIL(uchar) 0
7816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* number of code units per code point */
7836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_NEED_MULTIPLE_UCHAR(c) 0
7866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_CHAR_LENGTH(c) 1
7886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_MAX_CHAR_LENGTH 1
7906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* average number of code units compared to UTF-16 */
7926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_ARRAY_SIZE(size) (size)
7956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
7976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_GET_CHAR_UNSAFE(s, i, c) { \
7986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[i]; \
7996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
8036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[i]; \
8046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(!UTF32_IS_SAFE(c, strict)) { \
8056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF_ERROR_VALUE; \
8066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
8076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* definitions with forward iteration --------------------------------------- */
8106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \
8136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[(i)++]; \
8146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \
8186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (s)[(i)++]=(c); \
8196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_FWD_1_UNSAFE(s, i) { \
8236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    ++(i); \
8246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_FWD_N_UNSAFE(s, i, n) { \
8286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (i)+=(n); \
8296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_SET_CHAR_START_UNSAFE(s, i) { \
8336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
8376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[(i)++]; \
8386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(!UTF32_IS_SAFE(c, strict)) { \
8396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF_ERROR_VALUE; \
8406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
8416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \
8456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((uint32_t)(c)<=0x10ffff) { \
8466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=(c); \
8476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else /* c>0x10ffff, write 0xfffd */ { \
8486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (s)[(i)++]=0xfffd; \
8496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
8506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_FWD_1_SAFE(s, i, length) { \
8546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    ++(i); \
8556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_FWD_N_SAFE(s, i, length, n) { \
8596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(((i)+=(n))>(length)) { \
8606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (i)=(length); \
8616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
8626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_SET_CHAR_START_SAFE(s, start, i) { \
8666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* definitions with backward iteration -------------------------------------- */
8696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \
8726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[--(i)]; \
8736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_BACK_1_UNSAFE(s, i) { \
8776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    --(i); \
8786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_BACK_N_UNSAFE(s, i, n) { \
8826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (i)-=(n); \
8836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \
8876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \
8916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (c)=(s)[--(i)]; \
8926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(!UTF32_IS_SAFE(c, strict)) { \
8936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (c)=UTF_ERROR_VALUE; \
8946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
8956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
8966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
8976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
8986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_BACK_1_SAFE(s, start, i) { \
8996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    --(i); \
9006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
9016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
9036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_BACK_N_SAFE(s, start, i, n) { \
9046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    (i)-=(n); \
9056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if((i)<(start)) { \
9066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        (i)=(start); \
9076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } \
9086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
9096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
9116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \
9126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
9136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Formerly utf.h, part 2 --------------------------------------------------- */
9156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
9176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Estimate the number of code units for a string based on the number of UTF-16 code units.
9186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
9196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Obsolete, see utf_old.h.
9206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
9216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_ARRAY_SIZE(size) UTF16_ARRAY_SIZE(size)
9226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */
9246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_GET_CHAR_UNSAFE(s, i, c)                 UTF16_GET_CHAR_UNSAFE(s, i, c)
9256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */
9276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_GET_CHAR_SAFE(s, start, i, length, c, strict) UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict)
9286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */
9316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_NEXT_CHAR_UNSAFE(s, i, c)                UTF16_NEXT_CHAR_UNSAFE(s, i, c)
9326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */
9346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_NEXT_CHAR_SAFE(s, i, length, c, strict)  UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict)
9356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */
9386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_APPEND_CHAR_UNSAFE(s, i, c)              UTF16_APPEND_CHAR_UNSAFE(s, i, c)
9396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */
9416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_APPEND_CHAR_SAFE(s, i, length, c)        UTF16_APPEND_CHAR_SAFE(s, i, length, c)
9426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */
9456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FWD_1_UNSAFE(s, i)                       UTF16_FWD_1_UNSAFE(s, i)
9466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */
9486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FWD_1_SAFE(s, i, length)                 UTF16_FWD_1_SAFE(s, i, length)
9496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */
9526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FWD_N_UNSAFE(s, i, n)                    UTF16_FWD_N_UNSAFE(s, i, n)
9536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */
9556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FWD_N_SAFE(s, i, length, n)              UTF16_FWD_N_SAFE(s, i, length, n)
9566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */
9596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SET_CHAR_START_UNSAFE(s, i)              UTF16_SET_CHAR_START_UNSAFE(s, i)
9606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */
9626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SET_CHAR_START_SAFE(s, start, i)         UTF16_SET_CHAR_START_SAFE(s, start, i)
9636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */
9666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_PREV_CHAR_UNSAFE(s, i, c)                UTF16_PREV_CHAR_UNSAFE(s, i, c)
9676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */
9696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_PREV_CHAR_SAFE(s, start, i, c, strict)   UTF16_PREV_CHAR_SAFE(s, start, i, c, strict)
9706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */
9736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_BACK_1_UNSAFE(s, i)                      UTF16_BACK_1_UNSAFE(s, i)
9746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */
9766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_BACK_1_SAFE(s, start, i)                 UTF16_BACK_1_SAFE(s, start, i)
9776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */
9806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_BACK_N_UNSAFE(s, i, n)                   UTF16_BACK_N_UNSAFE(s, i, n)
9816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */
9836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_BACK_N_SAFE(s, start, i, n)              UTF16_BACK_N_SAFE(s, start, i, n)
9846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
9876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SET_CHAR_LIMIT_UNSAFE(s, i)              UTF16_SET_CHAR_LIMIT_UNSAFE(s, i)
9886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */
9906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length) UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length)
9916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* Define default macros (UTF-16 "safe") ------------------------------------ */
9936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
9946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
9956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Does this code unit alone encode a code point (BMP, not a surrogate)?
9966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_IS_SINGLE.
9976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U_IS_SINGLE and U16_IS_SINGLE, see utf_old.h.
9986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
9996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_SINGLE(uchar) U16_IS_SINGLE(uchar)
10006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Is this code unit the first one of several (a lead surrogate)?
10036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_IS_LEAD.
10046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h.
10056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_LEAD(uchar) U16_IS_LEAD(uchar)
10076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Is this code unit one of several but not the first one (a trail surrogate)?
10106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_IS_TRAIL.
10116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h.
10126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_IS_TRAIL(uchar) U16_IS_TRAIL(uchar)
10146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Does this code point require multiple code units (is it a supplementary code point)?
10176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_NEED_MULTIPLE_UCHAR.
10186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead.
10196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_NEED_MULTIPLE_UCHAR(c) UTF16_NEED_MULTIPLE_UCHAR(c)
10216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * How many code units are used to encode this code point (1 or 2)?
10246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_CHAR_LENGTH.
10256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h.
10266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_CHAR_LENGTH(c) U16_LENGTH(c)
10286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * How many code units are used at most for any Unicode code point (2)?
10316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_MAX_CHAR_LENGTH.
10326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h.
10336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_MAX_CHAR_LENGTH U16_MAX_LENGTH
10356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Set c to the code point that contains the code unit i.
10386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * i could point to the lead or the trail surrogate for the code point.
10396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * i is not modified.
10406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_GET_CHAR.
10416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre 0<=i<length
10426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
10436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_GET, see utf_old.h.
10446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_GET_CHAR(s, start, i, length, c) U16_GET(s, start, i, length, c)
10466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Set c to the code point that starts at code unit i
10496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * and advance i to beyond the code units of this code point (post-increment).
10506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * i must point to the first code unit of a code point.
10516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Otherwise c is set to the trail unit (surrogate) itself.
10526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_NEXT_CHAR.
10536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre 0<=i<length
10546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post 0<i<=length
10556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
10566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_NEXT, see utf_old.h.
10576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_NEXT_CHAR(s, i, length, c) U16_NEXT(s, i, length, c)
10596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Append the code units of code point c to the string at index i
10626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * and advance i to beyond the new code units (post-increment).
10636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The code units beginning at index i will be overwritten.
10646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_APPEND_CHAR.
10656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre 0<=c<=0x10ffff
10666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre 0<=i<length
10676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post 0<i<=length
10686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
10696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h.
10706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_APPEND_CHAR(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c)
10726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Advance i to beyond the code units of the code point that begins at i.
10756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * I.e., advance i by one code point.
10766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_FWD_1.
10776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre 0<=i<length
10786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post 0<i<=length
10796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
10806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h.
10816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FWD_1(s, i, length) U16_FWD_1(s, i, length)
10836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Advance i to beyond the code units of the n code points where the first one begins at i.
10866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * I.e., advance i by n code points.
10876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UT16_FWD_N.
10886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre 0<=i<length
10896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post 0<i<=length
10906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
10916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h.
10926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
10936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_FWD_N(s, i, length, n) U16_FWD_N(s, i, length, n)
10946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
10956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
10966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Take the random-access index i and adjust it so that it points to the beginning
10976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * of a code point.
10986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * The input index points to any code unit of a code point and is moved to point to
10996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * the first code unit of the same code point. i is never incremented.
11006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * In other words, if i points to a trail surrogate that is preceded by a matching
11016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * lead surrogate, then i is decremented. Otherwise it is not modified.
11026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This can be used to start an iteration with UTF_NEXT_CHAR() from a random index.
11036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_SET_CHAR_START.
11046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre start<=i<length
11056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post start<=i<length
11066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
11076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h.
11086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
11096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SET_CHAR_START(s, start, i) U16_SET_CP_START(s, start, i)
11106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
11116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
11126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Set c to the code point that has code units before i
11136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * and move i backward (towards the beginning of the string)
11146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * to the first code unit of this code point (pre-increment).
11156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * i must point to the first code unit after the last unit of a code point (i==length is allowed).
11166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_PREV_CHAR.
11176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre start<i<=length
11186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post start<=i<length
11196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
11206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_PREV, see utf_old.h.
11216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
11226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_PREV_CHAR(s, start, i, c) U16_PREV(s, start, i, c)
11236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
11246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
11256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Move i backward (towards the beginning of the string)
11266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * to the first code unit of the code point that has code units before i.
11276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * I.e., move i backward by one code point.
11286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * i must point to the first code unit after the last unit of a code point (i==length is allowed).
11296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_BACK_1.
11306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre start<i<=length
11316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post start<=i<length
11326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
11336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h.
11346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
11356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_BACK_1(s, start, i) U16_BACK_1(s, start, i)
11366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
11376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
11386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Move i backward (towards the beginning of the string)
11396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * to the first code unit of the n code points that have code units before i.
11406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * I.e., move i backward by n code points.
11416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * i must point to the first code unit after the last unit of a code point (i==length is allowed).
11426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_BACK_N.
11436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre start<i<=length
11446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post start<=i<length
11456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
11466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h.
11476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
11486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_BACK_N(s, start, i, n) U16_BACK_N(s, start, i, n)
11496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
11506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
11516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Take the random-access index i and adjust it so that it points beyond
11526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * a code point. The input index points beyond any code unit
11536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * of a code point and is moved to point beyond the last code unit of the same
11546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * code point. i is never decremented.
11556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * In other words, if i points to a trail surrogate that is preceded by a matching
11566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * lead surrogate, then i is incremented. Otherwise it is not modified.
11576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * This can be used to start an iteration with UTF_PREV_CHAR() from a random index.
11586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Same as UTF16_SET_CHAR_LIMIT.
11596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \pre start<i<=length
11606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * \post start<i<=length
11616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
11626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h.
11636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
11646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define UTF_SET_CHAR_LIMIT(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
11656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
11666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif /* U_HIDE_DEPRECATED_API */
11676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
11686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
11696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1170