11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci******************************************************************************* 51cb0ef41Sopenharmony_ci* Copyright (C) 2013-2015, International Business Machines 61cb0ef41Sopenharmony_ci* Corporation and others. All Rights Reserved. 71cb0ef41Sopenharmony_ci******************************************************************************* 81cb0ef41Sopenharmony_ci* collationfastlatin.h 91cb0ef41Sopenharmony_ci* 101cb0ef41Sopenharmony_ci* created on: 2013aug09 111cb0ef41Sopenharmony_ci* created by: Markus W. Scherer 121cb0ef41Sopenharmony_ci*/ 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci#ifndef __COLLATIONFASTLATIN_H__ 151cb0ef41Sopenharmony_ci#define __COLLATIONFASTLATIN_H__ 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci#if !UCONFIG_NO_COLLATION 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_cistruct CollationData; 241cb0ef41Sopenharmony_cistruct CollationSettings; 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciclass U_I18N_API CollationFastLatin /* all static */ { 271cb0ef41Sopenharmony_cipublic: 281cb0ef41Sopenharmony_ci /** 291cb0ef41Sopenharmony_ci * Fast Latin format version (one byte 1..FF). 301cb0ef41Sopenharmony_ci * Must be incremented for any runtime-incompatible changes, 311cb0ef41Sopenharmony_ci * in particular, for changes to any of the following constants. 321cb0ef41Sopenharmony_ci * 331cb0ef41Sopenharmony_ci * When the major version number of the main data format changes, 341cb0ef41Sopenharmony_ci * we can reset this fast Latin version to 1. 351cb0ef41Sopenharmony_ci */ 361cb0ef41Sopenharmony_ci static const uint16_t VERSION = 2; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci static const int32_t LATIN_MAX = 0x17f; 391cb0ef41Sopenharmony_ci static const int32_t LATIN_LIMIT = LATIN_MAX + 1; 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci static const int32_t LATIN_MAX_UTF8_LEAD = 0xc5; // UTF-8 lead byte of LATIN_MAX 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci static const int32_t PUNCT_START = 0x2000; 441cb0ef41Sopenharmony_ci static const int32_t PUNCT_LIMIT = 0x2040; 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci // excludes U+FFFE & U+FFFF 471cb0ef41Sopenharmony_ci static const int32_t NUM_FAST_CHARS = LATIN_LIMIT + (PUNCT_LIMIT - PUNCT_START); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci // Note on the supported weight ranges: 501cb0ef41Sopenharmony_ci // Analysis of UCA 6.3 and CLDR 23 non-search tailorings shows that 511cb0ef41Sopenharmony_ci // the CEs for characters in the above ranges, excluding expansions with length >2, 521cb0ef41Sopenharmony_ci // excluding contractions of >2 characters, and other restrictions 531cb0ef41Sopenharmony_ci // (see the builder's getCEsFromCE32()), 541cb0ef41Sopenharmony_ci // use at most about 150 primary weights, 551cb0ef41Sopenharmony_ci // where about 94 primary weights are possibly-variable (space/punct/symbol/currency), 561cb0ef41Sopenharmony_ci // at most 4 secondary before-common weights, 571cb0ef41Sopenharmony_ci // at most 4 secondary after-common weights, 581cb0ef41Sopenharmony_ci // at most 16 secondary high weights (in secondary CEs), and 591cb0ef41Sopenharmony_ci // at most 4 tertiary after-common weights. 601cb0ef41Sopenharmony_ci // The following ranges are designed to support slightly more weights than that. 611cb0ef41Sopenharmony_ci // (en_US_POSIX is unusual: It creates about 64 variable + 116 Latin primaries.) 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci // Digits may use long primaries (preserving more short ones) 641cb0ef41Sopenharmony_ci // or short primaries (faster) without changing this data structure. 651cb0ef41Sopenharmony_ci // (If we supported numeric collation, then digits would have to have long primaries 661cb0ef41Sopenharmony_ci // so that special handling does not affect the fast path.) 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci static const uint32_t SHORT_PRIMARY_MASK = 0xfc00; // bits 15..10 691cb0ef41Sopenharmony_ci static const uint32_t INDEX_MASK = 0x3ff; // bits 9..0 for expansions & contractions 701cb0ef41Sopenharmony_ci static const uint32_t SECONDARY_MASK = 0x3e0; // bits 9..5 711cb0ef41Sopenharmony_ci static const uint32_t CASE_MASK = 0x18; // bits 4..3 721cb0ef41Sopenharmony_ci static const uint32_t LONG_PRIMARY_MASK = 0xfff8; // bits 15..3 731cb0ef41Sopenharmony_ci static const uint32_t TERTIARY_MASK = 7; // bits 2..0 741cb0ef41Sopenharmony_ci static const uint32_t CASE_AND_TERTIARY_MASK = CASE_MASK | TERTIARY_MASK; 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ci static const uint32_t TWO_SHORT_PRIMARIES_MASK = 771cb0ef41Sopenharmony_ci (SHORT_PRIMARY_MASK << 16) | SHORT_PRIMARY_MASK; // 0xfc00fc00 781cb0ef41Sopenharmony_ci static const uint32_t TWO_LONG_PRIMARIES_MASK = 791cb0ef41Sopenharmony_ci (LONG_PRIMARY_MASK << 16) | LONG_PRIMARY_MASK; // 0xfff8fff8 801cb0ef41Sopenharmony_ci static const uint32_t TWO_SECONDARIES_MASK = 811cb0ef41Sopenharmony_ci (SECONDARY_MASK << 16) | SECONDARY_MASK; // 0x3e003e0 821cb0ef41Sopenharmony_ci static const uint32_t TWO_CASES_MASK = 831cb0ef41Sopenharmony_ci (CASE_MASK << 16) | CASE_MASK; // 0x180018 841cb0ef41Sopenharmony_ci static const uint32_t TWO_TERTIARIES_MASK = 851cb0ef41Sopenharmony_ci (TERTIARY_MASK << 16) | TERTIARY_MASK; // 0x70007 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci /** 881cb0ef41Sopenharmony_ci * Contraction with one fast Latin character. 891cb0ef41Sopenharmony_ci * Use INDEX_MASK to find the start of the contraction list after the fixed table. 901cb0ef41Sopenharmony_ci * The first entry contains the default mapping. 911cb0ef41Sopenharmony_ci * Otherwise use CONTR_CHAR_MASK for the contraction character index 921cb0ef41Sopenharmony_ci * (in ascending order). 931cb0ef41Sopenharmony_ci * Use CONTR_LENGTH_SHIFT for the length of the entry 941cb0ef41Sopenharmony_ci * (1=BAIL_OUT, 2=one CE, 3=two CEs). 951cb0ef41Sopenharmony_ci * 961cb0ef41Sopenharmony_ci * Also, U+0000 maps to a contraction entry, so that the fast path need not 971cb0ef41Sopenharmony_ci * check for NUL termination. 981cb0ef41Sopenharmony_ci * It usually maps to a contraction list with only the completely ignorable default value. 991cb0ef41Sopenharmony_ci */ 1001cb0ef41Sopenharmony_ci static const uint32_t CONTRACTION = 0x400; 1011cb0ef41Sopenharmony_ci /** 1021cb0ef41Sopenharmony_ci * An expansion encodes two CEs. 1031cb0ef41Sopenharmony_ci * Use INDEX_MASK to find the pair of CEs after the fixed table. 1041cb0ef41Sopenharmony_ci * 1051cb0ef41Sopenharmony_ci * The higher a mini CE value, the easier it is to process. 1061cb0ef41Sopenharmony_ci * For expansions and higher, no context needs to be considered. 1071cb0ef41Sopenharmony_ci */ 1081cb0ef41Sopenharmony_ci static const uint32_t EXPANSION = 0x800; 1091cb0ef41Sopenharmony_ci /** 1101cb0ef41Sopenharmony_ci * Encodes one CE with a long/low mini primary (there are 128). 1111cb0ef41Sopenharmony_ci * All potentially-variable primaries must be in this range, 1121cb0ef41Sopenharmony_ci * to make the short-primary path as fast as possible. 1131cb0ef41Sopenharmony_ci */ 1141cb0ef41Sopenharmony_ci static const uint32_t MIN_LONG = 0xc00; 1151cb0ef41Sopenharmony_ci static const uint32_t LONG_INC = 8; 1161cb0ef41Sopenharmony_ci static const uint32_t MAX_LONG = 0xff8; 1171cb0ef41Sopenharmony_ci /** 1181cb0ef41Sopenharmony_ci * Encodes one CE with a short/high primary (there are 60), 1191cb0ef41Sopenharmony_ci * plus a secondary CE if the secondary weight is high. 1201cb0ef41Sopenharmony_ci * Fast handling: At least all letter primaries should be in this range. 1211cb0ef41Sopenharmony_ci */ 1221cb0ef41Sopenharmony_ci static const uint32_t MIN_SHORT = 0x1000; 1231cb0ef41Sopenharmony_ci static const uint32_t SHORT_INC = 0x400; 1241cb0ef41Sopenharmony_ci /** The highest primary weight is reserved for U+FFFF. */ 1251cb0ef41Sopenharmony_ci static const uint32_t MAX_SHORT = SHORT_PRIMARY_MASK; 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci static const uint32_t MIN_SEC_BEFORE = 0; // must add SEC_OFFSET 1281cb0ef41Sopenharmony_ci static const uint32_t SEC_INC = 0x20; 1291cb0ef41Sopenharmony_ci static const uint32_t MAX_SEC_BEFORE = MIN_SEC_BEFORE + 4 * SEC_INC; // 5 before common 1301cb0ef41Sopenharmony_ci static const uint32_t COMMON_SEC = MAX_SEC_BEFORE + SEC_INC; 1311cb0ef41Sopenharmony_ci static const uint32_t MIN_SEC_AFTER = COMMON_SEC + SEC_INC; 1321cb0ef41Sopenharmony_ci static const uint32_t MAX_SEC_AFTER = MIN_SEC_AFTER + 5 * SEC_INC; // 6 after common 1331cb0ef41Sopenharmony_ci static const uint32_t MIN_SEC_HIGH = MAX_SEC_AFTER + SEC_INC; // 20 high secondaries 1341cb0ef41Sopenharmony_ci static const uint32_t MAX_SEC_HIGH = SECONDARY_MASK; 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ci /** 1371cb0ef41Sopenharmony_ci * Lookup: Add this offset to secondary weights, except for completely ignorable CEs. 1381cb0ef41Sopenharmony_ci * Must be greater than any special value, e.g., MERGE_WEIGHT. 1391cb0ef41Sopenharmony_ci * The exact value is not relevant for the format version. 1401cb0ef41Sopenharmony_ci */ 1411cb0ef41Sopenharmony_ci static const uint32_t SEC_OFFSET = SEC_INC; 1421cb0ef41Sopenharmony_ci static const uint32_t COMMON_SEC_PLUS_OFFSET = COMMON_SEC + SEC_OFFSET; 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci static const uint32_t TWO_SEC_OFFSETS = 1451cb0ef41Sopenharmony_ci (SEC_OFFSET << 16) | SEC_OFFSET; // 0x200020 1461cb0ef41Sopenharmony_ci static const uint32_t TWO_COMMON_SEC_PLUS_OFFSET = 1471cb0ef41Sopenharmony_ci (COMMON_SEC_PLUS_OFFSET << 16) | COMMON_SEC_PLUS_OFFSET; 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_ci static const uint32_t LOWER_CASE = 8; // case bits include this offset 1501cb0ef41Sopenharmony_ci static const uint32_t TWO_LOWER_CASES = (LOWER_CASE << 16) | LOWER_CASE; // 0x80008 1511cb0ef41Sopenharmony_ci 1521cb0ef41Sopenharmony_ci static const uint32_t COMMON_TER = 0; // must add TER_OFFSET 1531cb0ef41Sopenharmony_ci static const uint32_t MAX_TER_AFTER = 7; // 7 after common 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_ci /** 1561cb0ef41Sopenharmony_ci * Lookup: Add this offset to tertiary weights, except for completely ignorable CEs. 1571cb0ef41Sopenharmony_ci * Must be greater than any special value, e.g., MERGE_WEIGHT. 1581cb0ef41Sopenharmony_ci * Must be greater than case bits as well, so that with combined case+tertiary weights 1591cb0ef41Sopenharmony_ci * plus the offset the tertiary bits does not spill over into the case bits. 1601cb0ef41Sopenharmony_ci * The exact value is not relevant for the format version. 1611cb0ef41Sopenharmony_ci */ 1621cb0ef41Sopenharmony_ci static const uint32_t TER_OFFSET = SEC_OFFSET; 1631cb0ef41Sopenharmony_ci static const uint32_t COMMON_TER_PLUS_OFFSET = COMMON_TER + TER_OFFSET; 1641cb0ef41Sopenharmony_ci 1651cb0ef41Sopenharmony_ci static const uint32_t TWO_TER_OFFSETS = (TER_OFFSET << 16) | TER_OFFSET; 1661cb0ef41Sopenharmony_ci static const uint32_t TWO_COMMON_TER_PLUS_OFFSET = 1671cb0ef41Sopenharmony_ci (COMMON_TER_PLUS_OFFSET << 16) | COMMON_TER_PLUS_OFFSET; 1681cb0ef41Sopenharmony_ci 1691cb0ef41Sopenharmony_ci static const uint32_t MERGE_WEIGHT = 3; 1701cb0ef41Sopenharmony_ci static const uint32_t EOS = 2; // end of string 1711cb0ef41Sopenharmony_ci static const uint32_t BAIL_OUT = 1; 1721cb0ef41Sopenharmony_ci 1731cb0ef41Sopenharmony_ci /** 1741cb0ef41Sopenharmony_ci * Contraction result first word bits 8..0 contain the 1751cb0ef41Sopenharmony_ci * second contraction character, as a char index 0..NUM_FAST_CHARS-1. 1761cb0ef41Sopenharmony_ci * Each contraction list is terminated with a word containing CONTR_CHAR_MASK. 1771cb0ef41Sopenharmony_ci */ 1781cb0ef41Sopenharmony_ci static const uint32_t CONTR_CHAR_MASK = 0x1ff; 1791cb0ef41Sopenharmony_ci /** 1801cb0ef41Sopenharmony_ci * Contraction result first word bits 10..9 contain the result length: 1811cb0ef41Sopenharmony_ci * 1=bail out, 2=one mini CE, 3=two mini CEs 1821cb0ef41Sopenharmony_ci */ 1831cb0ef41Sopenharmony_ci static const uint32_t CONTR_LENGTH_SHIFT = 9; 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ci /** 1861cb0ef41Sopenharmony_ci * Comparison return value when the regular comparison must be used. 1871cb0ef41Sopenharmony_ci * The exact value is not relevant for the format version. 1881cb0ef41Sopenharmony_ci */ 1891cb0ef41Sopenharmony_ci static const int32_t BAIL_OUT_RESULT = -2; 1901cb0ef41Sopenharmony_ci 1911cb0ef41Sopenharmony_ci static inline int32_t getCharIndex(char16_t c) { 1921cb0ef41Sopenharmony_ci if(c <= LATIN_MAX) { 1931cb0ef41Sopenharmony_ci return c; 1941cb0ef41Sopenharmony_ci } else if(PUNCT_START <= c && c < PUNCT_LIMIT) { 1951cb0ef41Sopenharmony_ci return c - (PUNCT_START - LATIN_LIMIT); 1961cb0ef41Sopenharmony_ci } else { 1971cb0ef41Sopenharmony_ci // Not a fast Latin character. 1981cb0ef41Sopenharmony_ci // Note: U+FFFE & U+FFFF are forbidden in tailorings 1991cb0ef41Sopenharmony_ci // and thus do not occur in any contractions. 2001cb0ef41Sopenharmony_ci return -1; 2011cb0ef41Sopenharmony_ci } 2021cb0ef41Sopenharmony_ci } 2031cb0ef41Sopenharmony_ci 2041cb0ef41Sopenharmony_ci /** 2051cb0ef41Sopenharmony_ci * Computes the options value for the compare functions 2061cb0ef41Sopenharmony_ci * and writes the precomputed primary weights. 2071cb0ef41Sopenharmony_ci * Returns -1 if the Latin fastpath is not supported for the data and settings. 2081cb0ef41Sopenharmony_ci * The capacity must be LATIN_LIMIT. 2091cb0ef41Sopenharmony_ci */ 2101cb0ef41Sopenharmony_ci static int32_t getOptions(const CollationData *data, const CollationSettings &settings, 2111cb0ef41Sopenharmony_ci uint16_t *primaries, int32_t capacity); 2121cb0ef41Sopenharmony_ci 2131cb0ef41Sopenharmony_ci static int32_t compareUTF16(const uint16_t *table, const uint16_t *primaries, int32_t options, 2141cb0ef41Sopenharmony_ci const char16_t *left, int32_t leftLength, 2151cb0ef41Sopenharmony_ci const char16_t *right, int32_t rightLength); 2161cb0ef41Sopenharmony_ci 2171cb0ef41Sopenharmony_ci static int32_t compareUTF8(const uint16_t *table, const uint16_t *primaries, int32_t options, 2181cb0ef41Sopenharmony_ci const uint8_t *left, int32_t leftLength, 2191cb0ef41Sopenharmony_ci const uint8_t *right, int32_t rightLength); 2201cb0ef41Sopenharmony_ci 2211cb0ef41Sopenharmony_ciprivate: 2221cb0ef41Sopenharmony_ci static uint32_t lookup(const uint16_t *table, UChar32 c); 2231cb0ef41Sopenharmony_ci static uint32_t lookupUTF8(const uint16_t *table, UChar32 c, 2241cb0ef41Sopenharmony_ci const uint8_t *s8, int32_t &sIndex, int32_t sLength); 2251cb0ef41Sopenharmony_ci static uint32_t lookupUTF8Unsafe(const uint16_t *table, UChar32 c, 2261cb0ef41Sopenharmony_ci const uint8_t *s8, int32_t &sIndex); 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ci static uint32_t nextPair(const uint16_t *table, UChar32 c, uint32_t ce, 2291cb0ef41Sopenharmony_ci const char16_t *s16, const uint8_t *s8, int32_t &sIndex, int32_t &sLength); 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ci static inline uint32_t getPrimaries(uint32_t variableTop, uint32_t pair) { 2321cb0ef41Sopenharmony_ci uint32_t ce = pair & 0xffff; 2331cb0ef41Sopenharmony_ci if(ce >= MIN_SHORT) { return pair & TWO_SHORT_PRIMARIES_MASK; } 2341cb0ef41Sopenharmony_ci if(ce > variableTop) { return pair & TWO_LONG_PRIMARIES_MASK; } 2351cb0ef41Sopenharmony_ci if(ce >= MIN_LONG) { return 0; } // variable 2361cb0ef41Sopenharmony_ci return pair; // special mini CE 2371cb0ef41Sopenharmony_ci } 2381cb0ef41Sopenharmony_ci static inline uint32_t getSecondariesFromOneShortCE(uint32_t ce) { 2391cb0ef41Sopenharmony_ci ce &= SECONDARY_MASK; 2401cb0ef41Sopenharmony_ci if(ce < MIN_SEC_HIGH) { 2411cb0ef41Sopenharmony_ci return ce + SEC_OFFSET; 2421cb0ef41Sopenharmony_ci } else { 2431cb0ef41Sopenharmony_ci return ((ce + SEC_OFFSET) << 16) | COMMON_SEC_PLUS_OFFSET; 2441cb0ef41Sopenharmony_ci } 2451cb0ef41Sopenharmony_ci } 2461cb0ef41Sopenharmony_ci static uint32_t getSecondaries(uint32_t variableTop, uint32_t pair); 2471cb0ef41Sopenharmony_ci static uint32_t getCases(uint32_t variableTop, UBool strengthIsPrimary, uint32_t pair); 2481cb0ef41Sopenharmony_ci static uint32_t getTertiaries(uint32_t variableTop, UBool withCaseBits, uint32_t pair); 2491cb0ef41Sopenharmony_ci static uint32_t getQuaternaries(uint32_t variableTop, uint32_t pair); 2501cb0ef41Sopenharmony_ci 2511cb0ef41Sopenharmony_ciprivate: 2521cb0ef41Sopenharmony_ci CollationFastLatin() = delete; // no constructor 2531cb0ef41Sopenharmony_ci}; 2541cb0ef41Sopenharmony_ci 2551cb0ef41Sopenharmony_ci/* 2561cb0ef41Sopenharmony_ci * Format of the CollationFastLatin data table. 2571cb0ef41Sopenharmony_ci * CollationFastLatin::VERSION = 2. 2581cb0ef41Sopenharmony_ci * 2591cb0ef41Sopenharmony_ci * This table contains data for a Latin-text collation fastpath. 2601cb0ef41Sopenharmony_ci * The data is stored as an array of uint16_t which contains the following parts. 2611cb0ef41Sopenharmony_ci * 2621cb0ef41Sopenharmony_ci * uint16_t -- version & header length 2631cb0ef41Sopenharmony_ci * Bits 15..8: version, must match the VERSION 2641cb0ef41Sopenharmony_ci * 7..0: length of the header 2651cb0ef41Sopenharmony_ci * 2661cb0ef41Sopenharmony_ci * uint16_t varTops[header length - 1] 2671cb0ef41Sopenharmony_ci * Version 2: 2681cb0ef41Sopenharmony_ci * varTops[m] is the highest CollationFastLatin long-primary weight 2691cb0ef41Sopenharmony_ci * of supported maxVariable group m 2701cb0ef41Sopenharmony_ci * (special reorder group space, punct, symbol, currency). 2711cb0ef41Sopenharmony_ci * 2721cb0ef41Sopenharmony_ci * Version 1: 2731cb0ef41Sopenharmony_ci * Each of these values maps the variable top lead byte of a supported maxVariable group 2741cb0ef41Sopenharmony_ci * to the highest CollationFastLatin long-primary weight. 2751cb0ef41Sopenharmony_ci * The values are stored in ascending order. 2761cb0ef41Sopenharmony_ci * Bits 15..7: max fast-Latin long-primary weight (bits 11..3 shifted left by 4 bits) 2771cb0ef41Sopenharmony_ci * 6..0: regular primary lead byte 2781cb0ef41Sopenharmony_ci * 2791cb0ef41Sopenharmony_ci * uint16_t miniCEs[0x1c0] 2801cb0ef41Sopenharmony_ci * A mini collation element for each character U+0000..U+017F and U+2000..U+203F. 2811cb0ef41Sopenharmony_ci * Each value encodes one or two mini CEs (two are possible if the first one 2821cb0ef41Sopenharmony_ci * has a short mini primary and the second one is a secondary CE, i.e., primary == 0), 2831cb0ef41Sopenharmony_ci * or points to an expansion or to a contraction table. 2841cb0ef41Sopenharmony_ci * U+0000 always has a contraction entry, 2851cb0ef41Sopenharmony_ci * so that NUL-termination need not be tested in the fastpath. 2861cb0ef41Sopenharmony_ci * If the collation elements for a character or contraction cannot be encoded in this format, 2871cb0ef41Sopenharmony_ci * then the BAIL_OUT value is stored. 2881cb0ef41Sopenharmony_ci * For details see the comments for the class constants. 2891cb0ef41Sopenharmony_ci * 2901cb0ef41Sopenharmony_ci * uint16_t expansions[variable length]; 2911cb0ef41Sopenharmony_ci * Expansion mini CEs contain an offset relative to just after the miniCEs table. 2921cb0ef41Sopenharmony_ci * An expansions contains exactly 2 mini CEs. 2931cb0ef41Sopenharmony_ci * 2941cb0ef41Sopenharmony_ci * uint16_t contractions[variable length]; 2951cb0ef41Sopenharmony_ci * Contraction mini CEs contain an offset relative to just after the miniCEs table. 2961cb0ef41Sopenharmony_ci * It points to a list of tuples which map from a contraction suffix character to a result. 2971cb0ef41Sopenharmony_ci * First uint16_t of each tuple: 2981cb0ef41Sopenharmony_ci * Bits 10..9: Length of the result (1..3), see comments on CONTR_LENGTH_SHIFT. 2991cb0ef41Sopenharmony_ci * Bits 8..0: Contraction character, see comments on CONTR_CHAR_MASK. 3001cb0ef41Sopenharmony_ci * This is followed by 0, 1, or 2 uint16_t according to the length. 3011cb0ef41Sopenharmony_ci * Each list is terminated by an entry with CONTR_CHAR_MASK. 3021cb0ef41Sopenharmony_ci * Each list starts with such an entry which also contains the default result 3031cb0ef41Sopenharmony_ci * for when there is no contraction match. 3041cb0ef41Sopenharmony_ci * 3051cb0ef41Sopenharmony_ci * ----------------- 3061cb0ef41Sopenharmony_ci * Changes for version 2 (ICU 55) 3071cb0ef41Sopenharmony_ci * 3081cb0ef41Sopenharmony_ci * Special reorder groups do not necessarily start on whole primary lead bytes any more. 3091cb0ef41Sopenharmony_ci * Therefore, the varTops data has a new format: 3101cb0ef41Sopenharmony_ci * Version 1 stored the lead bytes of the highest root primaries for 3111cb0ef41Sopenharmony_ci * the maxVariable-supported special reorder groups. 3121cb0ef41Sopenharmony_ci * Now the top 16 bits would need to be stored, 3131cb0ef41Sopenharmony_ci * and it is simpler to store only the fast-Latin weights. 3141cb0ef41Sopenharmony_ci */ 3151cb0ef41Sopenharmony_ci 3161cb0ef41Sopenharmony_ciU_NAMESPACE_END 3171cb0ef41Sopenharmony_ci 3181cb0ef41Sopenharmony_ci#endif // !UCONFIG_NO_COLLATION 3191cb0ef41Sopenharmony_ci#endif // __COLLATIONFASTLATIN_H__ 320