os/textandloc/fontservices/textshaperplugin/IcuSource/common/ucnv_ext.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/ucnv_ext.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,463 @@
     1.4 +/*
     1.5 +******************************************************************************
     1.6 +*
     1.7 +*   Copyright (C) 2003-2004, International Business Machines
     1.8 +*   Corporation and others.  All Rights Reserved.
     1.9 +*
    1.10 +******************************************************************************
    1.11 +*   file name:  ucnv_ext.h
    1.12 +*   encoding:   US-ASCII
    1.13 +*   tab size:   8 (not used)
    1.14 +*   indentation:4
    1.15 +*
    1.16 +*   created on: 2003jun13
    1.17 +*   created by: Markus W. Scherer
    1.18 +*
    1.19 +*   Conversion extensions
    1.20 +*/
    1.21 +
    1.22 +#ifndef __UCNV_EXT_H__
    1.23 +#define __UCNV_EXT_H__
    1.24 +
    1.25 +#include "unicode/utypes.h"
    1.26 +
    1.27 +#if !UCONFIG_NO_CONVERSION
    1.28 +
    1.29 +#include "unicode/ucnv.h"
    1.30 +#include "ucnv_cnv.h"
    1.31 +
    1.32 +/*
    1.33 + * See icuhtml/design/conversion/conversion_extensions.html
    1.34 + *
    1.35 + * Conversion extensions serve two purposes:
    1.36 + * 1. They support m:n mappings.
    1.37 + * 2. They support extension-only conversion files that are used together
    1.38 + *    with the regular conversion data in base files.
    1.39 + *
    1.40 + * A base file may contain an extension table (explicitly requested or
    1.41 + * implicitly generated for m:n mappings), but its extension table is not
    1.42 + * used when an extension-only file is used.
    1.43 + *
    1.44 + * It is an error if a base file contains any regular (not extension) mapping
    1.45 + * from the same sequence as a mapping in the extension file
    1.46 + * because the base mapping would hide the extension mapping.
    1.47 + *
    1.48 + *
    1.49 + * Data for conversion extensions:
    1.50 + *
    1.51 + * One set of data structures per conversion direction (to/from Unicode).
    1.52 + * The data structures are sorted by input units to allow for binary search.
    1.53 + * Input sequences of more than one unit are handled like contraction tables
    1.54 + * in collation:
    1.55 + * The lookup value of a unit points to another table that is to be searched
    1.56 + * for the next unit, recursively.
    1.57 + *
    1.58 + * For conversion from Unicode, the initial code point is looked up in
    1.59 + * a 3-stage trie for speed,
    1.60 + * with an additional table of unique results to save space.
    1.61 + *
    1.62 + * Long output strings are stored in separate arrays, with length and index
    1.63 + * in the lookup tables.
    1.64 + * Output results also include a flag distinguishing roundtrip from
    1.65 + * (reverse) fallback mappings.
    1.66 + *
    1.67 + * Input Unicode strings must not begin or end with unpaired surrogates
    1.68 + * to avoid problems with matches on parts of surrogate pairs.
    1.69 + *
    1.70 + * Mappings from multiple characters (code points or codepage state
    1.71 + * table sequences) must be searched preferring the longest match.
    1.72 + * For this to work and be efficient, the variable-width table must contain
    1.73 + * all mappings that contain prefixes of the multiple characters.
    1.74 + * If an extension table is built on top of a base table in another file
    1.75 + * and a base table entry is a prefix of a multi-character mapping, then
    1.76 + * this is an error.
    1.77 + *
    1.78 + *
    1.79 + * Implementation note:
    1.80 + *
    1.81 + * Currently, the parser and several checks in the code limit the number
    1.82 + * of UChars or bytes in a mapping to
    1.83 + * UCNV_EXT_MAX_UCHARS and UCNV_EXT_MAX_BYTES, respectively,
    1.84 + * which are output value limits in the data structure.
    1.85 + *
    1.86 + * For input, this is not strictly necessary - it is a hard limit only for the
    1.87 + * buffers in UConverter that are used to store partial matches.
    1.88 + *
    1.89 + * Input sequences could otherwise be arbitrarily long if partial matches
    1.90 + * need not be stored (i.e., if a sequence does not span several buffers with too
    1.91 + * many units before the last buffer), although then results would differ
    1.92 + * depending on whether partial matches exceed the limits or not,
    1.93 + * which depends on the pattern of buffer sizes.
    1.94 + *
    1.95 + *
    1.96 + * Data structure:
    1.97 + *
    1.98 + * int32_t indexes[>=32];
    1.99 + *
   1.100 + *   Array of indexes and lengths etc. The length of the array is at least 32.
   1.101 + *   The actual length is stored in indexes[0] to be forward compatible.
   1.102 + *
   1.103 + *   Each index to another array is the number of bytes from indexes[].
   1.104 + *   Each length of an array is the number of array base units in that array.
   1.105 + *
   1.106 + *   Some of the structures may not be present, in which case their indexes
   1.107 + *   and lengths are 0.
   1.108 + *
   1.109 + *   Usage of indexes[i]:
   1.110 + *   [0]  length of indexes[]
   1.111 + *
   1.112 + *   // to Unicode table
   1.113 + *   [1]  index of toUTable[] (array of uint32_t)
   1.114 + *   [2]  length of toUTable[]
   1.115 + *   [3]  index of toUUChars[] (array of UChar)
   1.116 + *   [4]  length of toUUChars[]
   1.117 + *
   1.118 + *   // from Unicode table, not for the initial code point
   1.119 + *   [5]  index of fromUTableUChars[] (array of UChar)
   1.120 + *   [6]  index of fromUTableValues[] (array of uint32_t)
   1.121 + *   [7]  length of fromUTableUChars[] and fromUTableValues[]
   1.122 + *   [8]  index of fromUBytes[] (array of char)
   1.123 + *   [9]  length of fromUBytes[]
   1.124 + *
   1.125 + *   // from Unicode trie for initial-code point lookup
   1.126 + *   [10] index of fromUStage12[] (combined array of uint16_t for stages 1 & 2)
   1.127 + *   [11] length of stage 1 portion of fromUStage12[]
   1.128 + *   [12] length of fromUStage12[]
   1.129 + *   [13] index of fromUStage3[] (array of uint16_t indexes into fromUStage3b[])
   1.130 + *   [14] length of fromUStage3[]
   1.131 + *   [15] index of fromUStage3b[] (array of uint32_t like fromUTableValues[])
   1.132 + *   [16] length of fromUStage3b[]
   1.133 + *
   1.134 + *   [17] Bit field containing numbers of bytes:
   1.135 + *        31..24 reserved, 0
   1.136 + *        23..16 maximum input bytes
   1.137 + *        15.. 8 maximum output bytes
   1.138 + *         7.. 0 maximum bytes per UChar
   1.139 + *
   1.140 + *   [18] Bit field containing numbers of UChars:
   1.141 + *        31..24 reserved, 0
   1.142 + *        23..16 maximum input UChars
   1.143 + *        15.. 8 maximum output UChars
   1.144 + *         7.. 0 maximum UChars per byte
   1.145 + *
   1.146 + *   [19] Bit field containing flags:
   1.147 + *               (extension table unicodeMask)
   1.148 + *         1     UCNV_HAS_SURROGATES flag for the extension table
   1.149 + *         0     UCNV_HAS_SUPPLEMENTARY flag for the extension table
   1.150 + *
   1.151 + *   [20]..[30] reserved, 0
   1.152 + *   [31] number of bytes for the entire extension structure
   1.153 + *   [>31] reserved; there are indexes[0] indexes
   1.154 + *
   1.155 + *
   1.156 + * uint32_t toUTable[];
   1.157 + *
   1.158 + *   Array of byte/value pairs for lookups for toUnicode conversion.
   1.159 + *   The array is partitioned into sections like collation contraction tables.
   1.160 + *   Each section contains one word with the number of following words and
   1.161 + *   a default value for when the lookup in this section yields no match.
   1.162 + *
   1.163 + *   A section is sorted in ascending order of input bytes,
   1.164 + *   allowing for fast linear or binary searches.
   1.165 + *   The builder may store entries for a contiguous range of byte values
   1.166 + *   (compare difference between the first and last one with count),
   1.167 + *   which then allows for direct array access.
   1.168 + *   The builder should always do this for the initial table section.
   1.169 + *
   1.170 + *   Entries may have 0 values, see below.
   1.171 + *   No two entries in a section have the same byte values.
   1.172 + *
   1.173 + *   Each uint32_t contains an input byte value in bits 31..24 and the
   1.174 + *   corresponding lookup value in bits 23..0.
   1.175 + *   Interpret the value as follows:
   1.176 + *     if(value==0) {
   1.177 + *       no match, see below
   1.178 + *     } else if(value<0x1f0000) {
   1.179 + *       partial match - use value as index to the next toUTable section
   1.180 + *       and match the next unit; (value indexes toUTable[value])
   1.181 + *     } else {
   1.182 + *       if(bit 23 set) {
   1.183 + *         roundtrip;
   1.184 + *       } else {
   1.185 + *         fallback;
   1.186 + *       }
   1.187 + *       unset value bit 23;
   1.188 + *       if(value<=0x2fffff) {
   1.189 + *         (value-0x1f0000) is a code point; (BMP: value<=0x1fffff)
   1.190 + *       } else {
   1.191 + *         bits 17..0 (value&0x3ffff) is an index to
   1.192 + *           the result UChars in toUUChars[]; (0 indexes toUUChars[0])
   1.193 + *         length of the result=((value>>18)-12); (length=0..19)
   1.194 + *       }
   1.195 + *     }
   1.196 + *
   1.197 + *   The first word in a section contains the number of following words in the
   1.198 + *   input byte position (bits 31..24, number=1..0xff).
   1.199 + *   The value of the initial word is used when the current byte is not found
   1.200 + *   in this section.
   1.201 + *   If the value is not 0, then it represents a result as above.
   1.202 + *   If the value is 0, then the search has to return a shorter match with an
   1.203 + *   earlier default value as the result, or result in "unmappable" even for the
   1.204 + *   initial bytes.
   1.205 + *   If the value is 0 for the initial toUTable entry, then the initial byte
   1.206 + *   does not start any mapping input.
   1.207 + *
   1.208 + *
   1.209 + * UChar toUUChars[];
   1.210 + *
   1.211 + *   Contains toUnicode mapping results, stored as sequences of UChars.
   1.212 + *   Indexes and lengths stored in the toUTable[].
   1.213 + *
   1.214 + *
   1.215 + * UChar fromUTableUChars[];
   1.216 + * uint32_t fromUTableValues[];
   1.217 + *
   1.218 + *   The fromUTable is split into two arrays, but works otherwise much like
   1.219 + *   the toUTable. The array is partitioned into sections like collation
   1.220 + *   contraction tables and toUTable.
   1.221 + *   A row in the table consists of same-index entries in fromUTableUChars[]
   1.222 + *   and fromUTableValues[].
   1.223 + *
   1.224 + *   Interpret a value as follows:
   1.225 + *     if(value==0) {
   1.226 + *       no match, see below
   1.227 + *     } else if(value<=0xffffff) { (bits 31..24 are 0)
   1.228 + *       partial match - use value as index to the next fromUTable section
   1.229 + *       and match the next unit; (value indexes fromUTable[value])
   1.230 + *     } else {
   1.231 + *       if(value==0x80000001) {
   1.232 + *         return no mapping, but request for <subchar1>;
   1.233 + *       }
   1.234 + *       if(bit 31 set) {
   1.235 + *         roundtrip;
   1.236 + *       } else {
   1.237 + *         fallback;
   1.238 + *       }
   1.239 + *       // bits 30..29 reserved, 0
   1.240 + *       length=(value>>24)&0x1f; (bits 28..24)
   1.241 + *       if(length==1..3) {
   1.242 + *         bits 23..0 contain 1..3 bytes, padded with 00s on the left;
   1.243 + *       } else {
   1.244 + *         bits 23..0 (value&0xffffff) is an index to
   1.245 + *           the result bytes in fromUBytes[]; (0 indexes fromUBytes[0])
   1.246 + *       }
   1.247 + *     }
   1.248 + *       
   1.249 + *   The first pair in a section contains the number of following pairs in the
   1.250 + *   UChar position (16 bits, number=1..0xffff).
   1.251 + *   The value of the initial pair is used when the current UChar is not found
   1.252 + *   in this section.
   1.253 + *   If the value is not 0, then it represents a result as above.
   1.254 + *   If the value is 0, then the search has to return a shorter match with an
   1.255 + *   earlier default value as the result, or result in "unmappable" even for the
   1.256 + *   initial UChars.
   1.257 + *
   1.258 + *   If the from Unicode trie is present, then the from Unicode search tables
   1.259 + *   are not used for initial code points.
   1.260 + *   In this case, the first entries (index 0) in the tables are not used
   1.261 + *   (reserved, set to 0) because a value of 0 is used in trie results
   1.262 + *   to indicate no mapping.
   1.263 + *
   1.264 + *
   1.265 + * uint16_t fromUStage12[];
   1.266 + *
   1.267 + *   Stages 1 & 2 of a trie that maps an initial code point.
   1.268 + *   Indexes in stage 1 are all offset by the length of stage 1 so that the
   1.269 + *   same array pointer can be used for both stages.
   1.270 + *   If (c>>10)>=(length of stage 1) then c does not start any mapping.
   1.271 + *   Same bit distribution as for regular conversion tries.
   1.272 + *
   1.273 + *
   1.274 + * uint16_t fromUStage3[];
   1.275 + * uint32_t fromUStage3b[];
   1.276 + *
   1.277 + *   Stage 3 of the trie. The first array simply contains indexes to the second,
   1.278 + *   which contains words in the same format as fromUTableValues[].
   1.279 + *   Use a stage 3 granularity of 4, which allows for 256k stage 3 entries,
   1.280 + *   and 16-bit entries in stage 3 allow for 64k stage 3b entries.
   1.281 + *   The stage 3 granularity means that the stage 2 entry needs to be left-shifted.
   1.282 + *
   1.283 + *   Two arrays are used because it is expected that more than half of the stage 3
   1.284 + *   entries will be zero. The 16-bit index stage 3 array saves space even
   1.285 + *   considering storing a total of 6 bytes per non-zero entry in both arrays
   1.286 + *   together.
   1.287 + *   Using a stage 3 granularity of >1 diminishes the compactability in that stage
   1.288 + *   but provides a larger effective addressing space in stage 2.
   1.289 + *   All but the final result stage use 16-bit entries to save space.
   1.290 + *
   1.291 + *   fromUStage3b[] contains a zero for "no mapping" at its index 0,
   1.292 + *   and may contain UCNV_EXT_FROM_U_SUBCHAR1 at index 1 for "<subchar1> SUB mapping"
   1.293 + *   (i.e., "no mapping" with preference for <subchar1> rather than <subchar>),
   1.294 + *   and all other items are unique non-zero results.
   1.295 + *
   1.296 + *   The default value of a fromUTableValues[] section that is referenced
   1.297 + *   _directly_ from a fromUStage3b[] item may also be UCNV_EXT_FROM_U_SUBCHAR1,
   1.298 + *   but this value must not occur anywhere else in fromUTableValues[]
   1.299 + *   because "no mapping" is always a property of a single code point,
   1.300 + *   never of multiple.
   1.301 + *
   1.302 + *
   1.303 + * char fromUBytes[];
   1.304 + *
   1.305 + *   Contains fromUnicode mapping results, stored as sequences of chars.
   1.306 + *   Indexes and lengths stored in the fromUTableValues[].
   1.307 + */
   1.308 +enum {
   1.309 +    UCNV_EXT_INDEXES_LENGTH,            /* 0 */
   1.310 +
   1.311 +    UCNV_EXT_TO_U_INDEX,                /* 1 */
   1.312 +    UCNV_EXT_TO_U_LENGTH,
   1.313 +    UCNV_EXT_TO_U_UCHARS_INDEX,
   1.314 +    UCNV_EXT_TO_U_UCHARS_LENGTH,
   1.315 +
   1.316 +    UCNV_EXT_FROM_U_UCHARS_INDEX,       /* 5 */
   1.317 +    UCNV_EXT_FROM_U_VALUES_INDEX,
   1.318 +    UCNV_EXT_FROM_U_LENGTH,
   1.319 +    UCNV_EXT_FROM_U_BYTES_INDEX,
   1.320 +    UCNV_EXT_FROM_U_BYTES_LENGTH,
   1.321 +
   1.322 +    UCNV_EXT_FROM_U_STAGE_12_INDEX,     /* 10 */
   1.323 +    UCNV_EXT_FROM_U_STAGE_1_LENGTH,
   1.324 +    UCNV_EXT_FROM_U_STAGE_12_LENGTH,
   1.325 +    UCNV_EXT_FROM_U_STAGE_3_INDEX,
   1.326 +    UCNV_EXT_FROM_U_STAGE_3_LENGTH,
   1.327 +    UCNV_EXT_FROM_U_STAGE_3B_INDEX,
   1.328 +    UCNV_EXT_FROM_U_STAGE_3B_LENGTH,
   1.329 +
   1.330 +    UCNV_EXT_COUNT_BYTES,               /* 17 */
   1.331 +    UCNV_EXT_COUNT_UCHARS,
   1.332 +    UCNV_EXT_FLAGS,
   1.333 +
   1.334 +    UCNV_EXT_RESERVED_INDEX,            /* 20, moves with additional indexes */
   1.335 +
   1.336 +    UCNV_EXT_SIZE=31,
   1.337 +    UCNV_EXT_INDEXES_MIN_LENGTH=32
   1.338 +};
   1.339 +
   1.340 +/* get the pointer to an extension array from indexes[index] */
   1.341 +#define UCNV_EXT_ARRAY(indexes, index, itemType) \
   1.342 +    ((const itemType *)((const char *)(indexes)+(indexes)[index]))
   1.343 +
   1.344 +#define UCNV_GET_MAX_BYTES_PER_UCHAR(indexes) \
   1.345 +    ((indexes)[UCNV_EXT_COUNT_BYTES]&0xff)
   1.346 +
   1.347 +/* internal API ------------------------------------------------------------- */
   1.348 +
   1.349 +U_CFUNC UBool
   1.350 +ucnv_extInitialMatchToU(UConverter *cnv, const int32_t *cx,
   1.351 +                        int32_t firstLength,
   1.352 +                        const char **src, const char *srcLimit,
   1.353 +                        UChar **target, const UChar *targetLimit,
   1.354 +                        int32_t **offsets, int32_t srcIndex,
   1.355 +                        UBool flush,
   1.356 +                        UErrorCode *pErrorCode);
   1.357 +
   1.358 +U_CFUNC UChar32
   1.359 +ucnv_extSimpleMatchToU(const int32_t *cx,
   1.360 +                       const char *source, int32_t length,
   1.361 +                       UBool useFallback);
   1.362 +
   1.363 +U_CFUNC void
   1.364 +ucnv_extContinueMatchToU(UConverter *cnv,
   1.365 +                         UConverterToUnicodeArgs *pArgs, int32_t srcIndex,
   1.366 +                         UErrorCode *pErrorCode);
   1.367 +
   1.368 +
   1.369 +U_CFUNC UBool
   1.370 +ucnv_extInitialMatchFromU(UConverter *cnv, const int32_t *cx,
   1.371 +                          UChar32 cp,
   1.372 +                          const UChar **src, const UChar *srcLimit,
   1.373 +                          char **target, const char *targetLimit,
   1.374 +                          int32_t **offsets, int32_t srcIndex,
   1.375 +                          UBool flush,
   1.376 +                          UErrorCode *pErrorCode);
   1.377 +
   1.378 +U_CFUNC int32_t
   1.379 +ucnv_extSimpleMatchFromU(const int32_t *cx,
   1.380 +                         UChar32 cp, uint32_t *pValue,
   1.381 +                         UBool useFallback);
   1.382 +
   1.383 +U_CFUNC void
   1.384 +ucnv_extContinueMatchFromU(UConverter *cnv,
   1.385 +                           UConverterFromUnicodeArgs *pArgs, int32_t srcIndex,
   1.386 +                           UErrorCode *pErrorCode);
   1.387 +
   1.388 +U_CFUNC void
   1.389 +ucnv_extGetUnicodeSet(const UConverterSharedData *sharedData,
   1.390 +                      const USetAdder *sa,
   1.391 +                      UConverterUnicodeSet which,
   1.392 +                      UErrorCode *pErrorCode);
   1.393 +
   1.394 +/* toUnicode helpers -------------------------------------------------------- */
   1.395 +
   1.396 +#define UCNV_EXT_TO_U_BYTE_SHIFT 24
   1.397 +#define UCNV_EXT_TO_U_VALUE_MASK 0xffffff
   1.398 +#define UCNV_EXT_TO_U_MIN_CODE_POINT 0x1f0000
   1.399 +#define UCNV_EXT_TO_U_MAX_CODE_POINT 0x2fffff
   1.400 +#define UCNV_EXT_TO_U_ROUNDTRIP_FLAG ((uint32_t)1<<23)
   1.401 +#define UCNV_EXT_TO_U_INDEX_MASK 0x3ffff
   1.402 +#define UCNV_EXT_TO_U_LENGTH_SHIFT 18
   1.403 +#define UCNV_EXT_TO_U_LENGTH_OFFSET 12
   1.404 +
   1.405 +/* maximum number of indexed UChars */
   1.406 +#define UCNV_EXT_MAX_UCHARS 19
   1.407 +
   1.408 +#define UCNV_EXT_TO_U_MAKE_WORD(byte, value) (((uint32_t)(byte)<<UCNV_EXT_TO_U_BYTE_SHIFT)|(value))
   1.409 +
   1.410 +#define UCNV_EXT_TO_U_GET_BYTE(word) ((word)>>UCNV_EXT_TO_U_BYTE_SHIFT)
   1.411 +#define UCNV_EXT_TO_U_GET_VALUE(word) ((word)&UCNV_EXT_TO_U_VALUE_MASK)
   1.412 +
   1.413 +#define UCNV_EXT_TO_U_IS_PARTIAL(value) ((value)<UCNV_EXT_TO_U_MIN_CODE_POINT)
   1.414 +#define UCNV_EXT_TO_U_GET_PARTIAL_INDEX(value) (value)
   1.415 +
   1.416 +#define UCNV_EXT_TO_U_IS_ROUNDTRIP(value) (((value)&UCNV_EXT_TO_U_ROUNDTRIP_FLAG)!=0)
   1.417 +#define UCNV_EXT_TO_U_MASK_ROUNDTRIP(value) ((value)&~UCNV_EXT_TO_U_ROUNDTRIP_FLAG)
   1.418 +
   1.419 +/* use after masking off the roundtrip flag */
   1.420 +#define UCNV_EXT_TO_U_IS_CODE_POINT(value) ((value)<=UCNV_EXT_TO_U_MAX_CODE_POINT)
   1.421 +#define UCNV_EXT_TO_U_GET_CODE_POINT(value) ((value)-UCNV_EXT_TO_U_MIN_CODE_POINT)
   1.422 +
   1.423 +#define UCNV_EXT_TO_U_GET_INDEX(value) ((value)&UCNV_EXT_TO_U_INDEX_MASK)
   1.424 +#define UCNV_EXT_TO_U_GET_LENGTH(value) (((value)>>UCNV_EXT_TO_U_LENGTH_SHIFT)-UCNV_EXT_TO_U_LENGTH_OFFSET)
   1.425 +
   1.426 +/* fromUnicode helpers ------------------------------------------------------ */
   1.427 +
   1.428 +/* most trie constants are shared with ucnvmbcs.h */
   1.429 +
   1.430 +/* see similar utrie.h UTRIE_INDEX_SHIFT and UTRIE_DATA_GRANULARITY */
   1.431 +#define UCNV_EXT_STAGE_2_LEFT_SHIFT 2
   1.432 +#define UCNV_EXT_STAGE_3_GRANULARITY 4
   1.433 +
   1.434 +/* trie access, returns the stage 3 value=index to stage 3b; s1Index=c>>10 */
   1.435 +#define UCNV_EXT_FROM_U(stage12, stage3, s1Index, c) \
   1.436 +    (stage3)[ ((int32_t)(stage12)[ (stage12)[s1Index] +(((c)>>4)&0x3f) ]<<UCNV_EXT_STAGE_2_LEFT_SHIFT) +((c)&0xf) ]
   1.437 +
   1.438 +#define UCNV_EXT_FROM_U_LENGTH_SHIFT 24
   1.439 +#define UCNV_EXT_FROM_U_ROUNDTRIP_FLAG ((uint32_t)1<<31)
   1.440 +#define UCNV_EXT_FROM_U_RESERVED_MASK 0x60000000
   1.441 +#define UCNV_EXT_FROM_U_DATA_MASK 0xffffff
   1.442 +
   1.443 +/* special value for "no mapping" to <subchar1> (impossible roundtrip to 0 bytes, value 01) */
   1.444 +#define UCNV_EXT_FROM_U_SUBCHAR1 0x80000001
   1.445 +
   1.446 +/* at most 3 bytes in the lower part of the value */
   1.447 +#define UCNV_EXT_FROM_U_MAX_DIRECT_LENGTH 3
   1.448 +
   1.449 +/* maximum number of indexed bytes */
   1.450 +#define UCNV_EXT_MAX_BYTES 0x1f
   1.451 +
   1.452 +#define UCNV_EXT_FROM_U_IS_PARTIAL(value) (((value)>>UCNV_EXT_FROM_U_LENGTH_SHIFT)==0)
   1.453 +#define UCNV_EXT_FROM_U_GET_PARTIAL_INDEX(value) (value)
   1.454 +
   1.455 +#define UCNV_EXT_FROM_U_IS_ROUNDTRIP(value) (((value)&UCNV_EXT_FROM_U_ROUNDTRIP_FLAG)!=0)
   1.456 +#define UCNV_EXT_FROM_U_MASK_ROUNDTRIP(value) ((value)&~UCNV_EXT_FROM_U_ROUNDTRIP_FLAG)
   1.457 +
   1.458 +/* use after masking off the roundtrip flag */
   1.459 +#define UCNV_EXT_FROM_U_GET_LENGTH(value) (int32_t)(((value)>>UCNV_EXT_FROM_U_LENGTH_SHIFT)&UCNV_EXT_MAX_BYTES)
   1.460 +
   1.461 +/* get bytes or bytes index */
   1.462 +#define UCNV_EXT_FROM_U_GET_DATA(value) ((value)&UCNV_EXT_FROM_U_DATA_MASK)
   1.463 +
   1.464 +#endif
   1.465 +
   1.466 +#endif