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