10596faeddefbf198de137d5e893708495ab1584cFredrik Roubert// © 2016 and later: Unicode, Inc. and others. 264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html 3fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius/* 4fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius******************************************************************************* 51b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert* Copyright (C) 2010-2015, International Business Machines 6fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius* Corporation and others. All Rights Reserved. 7fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius******************************************************************************* 8fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius* collationdata.h 9fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius* 10fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius* created on: 2010oct27 11fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius* created by: Markus W. Scherer 12fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius*/ 13fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 14fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#ifndef __COLLATIONDATA_H__ 15fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#define __COLLATIONDATA_H__ 16fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 17fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#include "unicode/utypes.h" 18fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 19fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#if !UCONFIG_NO_COLLATION 20fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 211b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert#include "unicode/ucol.h" 22fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#include "unicode/uniset.h" 23fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#include "collation.h" 24fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#include "normalizer2impl.h" 25fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#include "utrie2.h" 26fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 27fceb39872958b9fa2505e63f8b8699a9e0f882f4ccorneliusstruct UDataMemory; 28fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 29fceb39872958b9fa2505e63f8b8699a9e0f882f4ccorneliusU_NAMESPACE_BEGIN 30fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 311b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubertclass UVector32; 321b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert 33fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius/** 34fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Collation data container. 35fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Immutable data created by a CollationDataBuilder, or loaded from a file, 36fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * or deserialized from API-provided binary data. 37fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * 38fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Includes data for the collation base (root/default), aliased if this is not the base. 39fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 40fceb39872958b9fa2505e63f8b8699a9e0f882f4ccorneliusstruct U_I18N_API CollationData : public UMemory { 411b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert // Note: The ucadata.icu loader could discover the reserved ranges by setting an array 421b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert // parallel with the ranges, and resetting ranges that are indexed. 431b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert // The reordering builder code could clone the resulting template array. 441b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert enum { 451b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert REORDER_RESERVED_BEFORE_LATIN = UCOL_REORDER_CODE_FIRST + 14, 461b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert REORDER_RESERVED_AFTER_LATIN 471b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert }; 481b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert 491b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert enum { 501b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert MAX_NUM_SPECIAL_REORDER_CODES = 8, 511b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert /** C++ only, data reader check scriptStartsLength. */ 521b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert MAX_NUM_SCRIPT_RANGES = 256 531b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert }; 541b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert 55fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius CollationData(const Normalizer2Impl &nfc) 56fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius : trie(NULL), 57fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius ce32s(NULL), ces(NULL), contexts(NULL), base(NULL), 58fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius jamoCE32s(NULL), 59fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius nfcImpl(nfc), 60fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius numericPrimary(0x12000000), 61fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius ce32sLength(0), cesLength(0), contextsLength(0), 62fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius compressibleBytes(NULL), 63fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius unsafeBackwardSet(NULL), 64fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius fastLatinTable(NULL), fastLatinTableLength(0), 651b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert numScripts(0), scriptsIndex(NULL), scriptStarts(NULL), scriptStartsLength(0), 66fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius rootElements(NULL), rootElementsLength(0) {} 67fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 68fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t getCE32(UChar32 c) const { 69fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return UTRIE2_GET32(trie, c); 70fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 71fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 72fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t getCE32FromSupplementary(UChar32 c) const { 73fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return UTRIE2_GET32_FROM_SUPP(trie, c); 74fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 75fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 76fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius UBool isDigit(UChar32 c) const { 77fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return c < 0x660 ? c <= 0x39 && 0x30 <= c : 78fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius Collation::hasCE32Tag(getCE32(c), Collation::DIGIT_TAG); 79fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 80fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 81fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius UBool isUnsafeBackward(UChar32 c, UBool numeric) const { 82fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return unsafeBackwardSet->contains(c) || (numeric && isDigit(c)); 83fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 84fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 85fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius UBool isCompressibleLeadByte(uint32_t b) const { 86fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return compressibleBytes[b]; 87fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 88fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 89fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius inline UBool isCompressiblePrimary(uint32_t p) const { 90fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return isCompressibleLeadByte(p >> 24); 91fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 92fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 93fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 94fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Returns the CE32 from two contexts words. 95fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Access to the defaultCE32 for contraction and prefix matching. 96fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 97fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius static uint32_t readCE32(const UChar *p) { 98fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return ((uint32_t)p[0] << 16) | p[1]; 99fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 100fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 101fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 102fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Returns the CE32 for an indirect special CE32 (e.g., with DIGIT_TAG). 103fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Requires that ce32 is special. 104fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 105fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t getIndirectCE32(uint32_t ce32) const; 106fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 107fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Returns the CE32 for an indirect special CE32 (e.g., with DIGIT_TAG), 108fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * if ce32 is special. 109fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 110fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t getFinalCE32(uint32_t ce32) const; 111fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 112fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 113fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Computes a CE from c's ce32 which has the OFFSET_TAG. 114fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 115fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int64_t getCEFromOffsetCE32(UChar32 c, uint32_t ce32) const { 116fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int64_t dataCE = ces[Collation::indexFromCE32(ce32)]; 117fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return Collation::makeCE(Collation::getThreeBytePrimaryForOffsetData(c, dataCE)); 118fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 119fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 120fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 121f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * Returns the single CE that c maps to. 122f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius * Sets U_UNSUPPORTED_ERROR if c does not map to a single CE. 123f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius */ 124f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius int64_t getSingleCE(UChar32 c, UErrorCode &errorCode) const; 125f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius 126f9878a236aa0d9662d8e40cafdaf2e04cd615835ccornelius /** 127fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Returns the FCD16 value for code point c. c must be >= 0. 128fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 129fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint16_t getFCD16(UChar32 c) const { 130fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius return nfcImpl.getFCD16(c); 131fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius } 132fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 133fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 134fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Returns the first primary for the script's reordering group. 135fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @return the primary with only the first primary lead byte of the group 136fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * (not necessarily an actual root collator primary weight), 137fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * or 0 if the script is unknown 138fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 139fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t getFirstPrimaryForGroup(int32_t script) const; 140fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 141fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 142fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Returns the last primary for the script's reordering group. 143fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @return the last primary of the group 144fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * (not an actual root collator primary weight), 145fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * or 0 if the script is unknown 146fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 147fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t getLastPrimaryForGroup(int32_t script) const; 148fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 149fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 150fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Finds the reordering group which contains the primary weight. 151fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * @return the first script of the group, or -1 if the weight is beyond the last group 152fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 153fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t getGroupForPrimary(uint32_t p) const; 154fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 155fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t getEquivalentScripts(int32_t script, 156fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t dest[], int32_t capacity, UErrorCode &errorCode) const; 157fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 158fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 1591b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * Writes the permutation of primary-weight ranges 1601b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * for the given reordering of scripts and groups. 161fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * The caller checks for illegal arguments and 162fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * takes care of [DEFAULT] and memory allocation. 1631b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * 1641b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * Each list element will be a (limit, offset) pair as described 1651b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * for the CollationSettings::reorderRanges. 1661b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * The list will be empty if no ranges are reordered. 167fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 1681b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert void makeReorderRanges(const int32_t *reorder, int32_t length, 1691b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert UVector32 &ranges, UErrorCode &errorCode) const; 170fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 171fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** @see jamoCE32s */ 172fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius static const int32_t JAMO_CE32S_LENGTH = 19 + 21 + 27; 173fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 174fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** Main lookup trie. */ 175fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const UTrie2 *trie; 176fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 177fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Array of CE32 values. 178fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * At index 0 there must be CE32(U+0000) 179fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * to support U+0000's special-tag for NUL-termination handling. 180fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 181fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const uint32_t *ce32s; 182fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** Array of CE values for expansions and OFFSET_TAG. */ 183fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const int64_t *ces; 184fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** Array of prefix and contraction-suffix matching data. */ 185fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const UChar *contexts; 186fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** Base collation data, or NULL if this data itself is a base. */ 187fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const CollationData *base; 188fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 189fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Simple array of JAMO_CE32S_LENGTH=19+21+27 CE32s, one per canonical Jamo L/V/T. 190fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * They are normally simple CE32s, rarely expansions. 191fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * For fast handling of HANGUL_TAG. 192fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 193fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const uint32_t *jamoCE32s; 194fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const Normalizer2Impl &nfcImpl; 195fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** The single-byte primary weight (xx000000) for numeric collation. */ 196fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius uint32_t numericPrimary; 197fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 198fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t ce32sLength; 199fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t cesLength; 200fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t contextsLength; 201fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 202fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 256 flags for which primary-weight lead bytes are compressible. */ 203fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const UBool *compressibleBytes; 204fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 205fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Set of code points that are unsafe for starting string comparison after an identical prefix, 206fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * or in backwards CE iteration. 207fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 208fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const UnicodeSet *unsafeBackwardSet; 209fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 210fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 211fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Fast Latin table for common-Latin-text string comparisons. 212fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Data structure see class CollationFastLatin. 213fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 214fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const uint16_t *fastLatinTable; 215fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t fastLatinTableLength; 216fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 217fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 218fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Data for scripts and reordering groups. 219fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Uses include building a reordering permutation table and 220fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * providing script boundaries to AlphabeticIndex. 2211b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert */ 2221b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert int32_t numScripts; 2231b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert /** 2241b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * The length of scriptsIndex is numScripts+16. 2251b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * It maps from a UScriptCode or a special reorder code to an entry in scriptStarts. 2261b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * 16 special reorder codes (not all used) are mapped starting at numScripts. 2271b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * Up to MAX_NUM_SPECIAL_REORDER_CODES are codes for special groups like space/punct/digit. 2281b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * There are special codes at the end for reorder-reserved primary ranges. 229fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * 2301b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * Multiple scripts may share a range and index, for example Hira & Kana. 2311b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert */ 2321b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert const uint16_t *scriptsIndex; 2331b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert /** 2341b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * Start primary weight (top 16 bits only) for a group/script/reserved range 2351b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * indexed by scriptsIndex. 2361b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * The first range (separators & terminators) and the last range (trailing weights) 2371b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert * are not reorderable, and no scriptsIndex entry points to them. 238fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 2391b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert const uint16_t *scriptStarts; 2401b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert int32_t scriptStartsLength; 241fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 242fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius /** 243fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Collation elements in the root collator. 244fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Used by the CollationRootElements class. The data structure is described there. 245fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * NULL in a tailoring. 246fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius */ 247fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius const uint32_t *rootElements; 248fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius int32_t rootElementsLength; 249fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 250fceb39872958b9fa2505e63f8b8699a9e0f882f4ccorneliusprivate: 2511b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert int32_t getScriptIndex(int32_t script) const; 2521b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert void makeReorderRanges(const int32_t *reorder, int32_t length, 2531b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert UBool latinMustMove, 2541b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert UVector32 &ranges, UErrorCode &errorCode) const; 2551b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert int32_t addLowScriptRange(uint8_t table[], int32_t index, int32_t lowStart) const; 2561b7d32f919554dda9c193b32188251337bc756f1Fredrik Roubert int32_t addHighScriptRange(uint8_t table[], int32_t index, int32_t highLimit) const; 257fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius}; 258fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 259fceb39872958b9fa2505e63f8b8699a9e0f882f4ccorneliusU_NAMESPACE_END 260fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius 261fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#endif // !UCONFIG_NO_COLLATION 262fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius#endif // __COLLATIONDATA_H__ 263