intl/icu/source/common/unormimp.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2001-2011, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 * file name: unormimp.h
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * created on: 2001may25
michael@0 14 * created by: Markus W. Scherer
michael@0 15 */
michael@0 16
michael@0 17 #ifndef __UNORMIMP_H__
michael@0 18 #define __UNORMIMP_H__
michael@0 19
michael@0 20 #include "unicode/utypes.h"
michael@0 21
michael@0 22 #if !UCONFIG_NO_NORMALIZATION
michael@0 23
michael@0 24 #include "udataswp.h"
michael@0 25
michael@0 26 /*
michael@0 27 * The 2001-2010 implementation of the normalization code loads its data from
michael@0 28 * unorm.icu, which is generated with the gennorm tool.
michael@0 29 * The format of that file is described at the end of this file.
michael@0 30 */
michael@0 31
michael@0 32 /* norm32 value constants */
michael@0 33 enum {
michael@0 34 /* quick check flags 0..3 set mean "no" for their forms */
michael@0 35 _NORM_QC_NFC=0x11, /* no|maybe */
michael@0 36 _NORM_QC_NFKC=0x22, /* no|maybe */
michael@0 37 _NORM_QC_NFD=4, /* no */
michael@0 38 _NORM_QC_NFKD=8, /* no */
michael@0 39
michael@0 40 _NORM_QC_ANY_NO=0xf,
michael@0 41
michael@0 42 /* quick check flags 4..5 mean "maybe" for their forms; test flags>=_NORM_QC_MAYBE */
michael@0 43 _NORM_QC_MAYBE=0x10,
michael@0 44 _NORM_QC_ANY_MAYBE=0x30,
michael@0 45
michael@0 46 _NORM_QC_MASK=0x3f,
michael@0 47
michael@0 48 _NORM_COMBINES_FWD=0x40,
michael@0 49 _NORM_COMBINES_BACK=0x80,
michael@0 50 _NORM_COMBINES_ANY=0xc0,
michael@0 51
michael@0 52 _NORM_CC_SHIFT=8, /* UnicodeData.txt combining class in bits 15..8 */
michael@0 53 _NORM_CC_MASK=0xff00,
michael@0 54
michael@0 55 _NORM_EXTRA_SHIFT=16, /* 16 bits for the index to UChars and other extra data */
michael@0 56 _NORM_EXTRA_INDEX_TOP=0xfc00, /* start of surrogate specials after shift */
michael@0 57
michael@0 58 _NORM_EXTRA_SURROGATE_MASK=0x3ff,
michael@0 59 _NORM_EXTRA_SURROGATE_TOP=0x3f0, /* hangul etc. */
michael@0 60
michael@0 61 _NORM_EXTRA_HANGUL=_NORM_EXTRA_SURROGATE_TOP,
michael@0 62 _NORM_EXTRA_JAMO_L,
michael@0 63 _NORM_EXTRA_JAMO_V,
michael@0 64 _NORM_EXTRA_JAMO_T
michael@0 65 };
michael@0 66
michael@0 67 /* norm32 value constants using >16 bits */
michael@0 68 #define _NORM_MIN_SPECIAL 0xfc000000
michael@0 69 #define _NORM_SURROGATES_TOP 0xfff00000
michael@0 70 #define _NORM_MIN_HANGUL 0xfff00000
michael@0 71 #define _NORM_MIN_JAMO_V 0xfff20000
michael@0 72 #define _NORM_JAMO_V_TOP 0xfff30000
michael@0 73
michael@0 74 /* value constants for auxTrie */
michael@0 75 enum {
michael@0 76 _NORM_AUX_COMP_EX_SHIFT=10,
michael@0 77 _NORM_AUX_UNSAFE_SHIFT=11,
michael@0 78 _NORM_AUX_NFC_SKIPPABLE_F_SHIFT=12
michael@0 79 };
michael@0 80
michael@0 81 #define _NORM_AUX_MAX_FNC ((int32_t)1<<_NORM_AUX_COMP_EX_SHIFT)
michael@0 82
michael@0 83 #define _NORM_AUX_FNC_MASK (uint32_t)(_NORM_AUX_MAX_FNC-1)
michael@0 84 #define _NORM_AUX_COMP_EX_MASK ((uint32_t)1<<_NORM_AUX_COMP_EX_SHIFT)
michael@0 85 #define _NORM_AUX_UNSAFE_MASK ((uint32_t)1<<_NORM_AUX_UNSAFE_SHIFT)
michael@0 86 #define _NORM_AUX_NFC_SKIP_F_MASK ((uint32_t)1<<_NORM_AUX_NFC_SKIPPABLE_F_SHIFT)
michael@0 87
michael@0 88 /* canonStartSets[0..31] contains indexes for what is in the array */
michael@0 89 enum {
michael@0 90 _NORM_SET_INDEX_CANON_SETS_LENGTH, /* number of uint16_t in canonical starter sets */
michael@0 91 _NORM_SET_INDEX_CANON_BMP_TABLE_LENGTH, /* number of uint16_t in the BMP search table (contains pairs) */
michael@0 92 _NORM_SET_INDEX_CANON_SUPP_TABLE_LENGTH,/* number of uint16_t in the supplementary search table (contains triplets) */
michael@0 93
michael@0 94 /* from formatVersion 2.3: */
michael@0 95 _NORM_SET_INDEX_NX_CJK_COMPAT_OFFSET, /* uint16_t offset from canonStartSets[0] to the
michael@0 96 exclusion set for CJK compatibility characters */
michael@0 97 _NORM_SET_INDEX_NX_UNICODE32_OFFSET, /* uint16_t offset from canonStartSets[0] to the
michael@0 98 exclusion set for Unicode 3.2 characters */
michael@0 99 _NORM_SET_INDEX_NX_RESERVED_OFFSET, /* uint16_t offset from canonStartSets[0] to the
michael@0 100 end of the previous exclusion set */
michael@0 101
michael@0 102 _NORM_SET_INDEX_TOP=32 /* changing this requires a new formatVersion */
michael@0 103 };
michael@0 104
michael@0 105 /* more constants for canonical starter sets */
michael@0 106
michael@0 107 /* 14 bit indexes to canonical USerializedSets */
michael@0 108 #define _NORM_MAX_CANON_SETS 0x4000
michael@0 109
michael@0 110 /* single-code point BMP sets are encoded directly in the search table except if result=0x4000..0x7fff */
michael@0 111 #define _NORM_CANON_SET_BMP_MASK 0xc000
michael@0 112 #define _NORM_CANON_SET_BMP_IS_INDEX 0x4000
michael@0 113
michael@0 114 /* indexes[] value names */
michael@0 115 enum {
michael@0 116 _NORM_INDEX_TRIE_SIZE, /* number of bytes in normalization trie */
michael@0 117 _NORM_INDEX_UCHAR_COUNT, /* number of UChars in extra data */
michael@0 118
michael@0 119 _NORM_INDEX_COMBINE_DATA_COUNT, /* number of uint16_t words for combining data */
michael@0 120 _NORM_INDEX_COMBINE_FWD_COUNT, /* number of code points that combine forward */
michael@0 121 _NORM_INDEX_COMBINE_BOTH_COUNT, /* number of code points that combine forward and backward */
michael@0 122 _NORM_INDEX_COMBINE_BACK_COUNT, /* number of code points that combine backward */
michael@0 123
michael@0 124 _NORM_INDEX_MIN_NFC_NO_MAYBE, /* first code point with quick check NFC NO/MAYBE */
michael@0 125 _NORM_INDEX_MIN_NFKC_NO_MAYBE, /* first code point with quick check NFKC NO/MAYBE */
michael@0 126 _NORM_INDEX_MIN_NFD_NO_MAYBE, /* first code point with quick check NFD NO/MAYBE */
michael@0 127 _NORM_INDEX_MIN_NFKD_NO_MAYBE, /* first code point with quick check NFKD NO/MAYBE */
michael@0 128
michael@0 129 _NORM_INDEX_FCD_TRIE_SIZE, /* number of bytes in FCD trie */
michael@0 130
michael@0 131 _NORM_INDEX_AUX_TRIE_SIZE, /* number of bytes in the auxiliary trie */
michael@0 132 _NORM_INDEX_CANON_SET_COUNT, /* number of uint16_t in the array of serialized USet */
michael@0 133
michael@0 134 _NORM_INDEX_TOP=32 /* changing this requires a new formatVersion */
michael@0 135 };
michael@0 136
michael@0 137 enum {
michael@0 138 /* FCD check: everything below this code point is known to have a 0 lead combining class */
michael@0 139 _NORM_MIN_WITH_LEAD_CC=0x300
michael@0 140 };
michael@0 141
michael@0 142 enum {
michael@0 143 /**
michael@0 144 * Bit 7 of the length byte for a decomposition string in extra data is
michael@0 145 * a flag indicating whether the decomposition string is
michael@0 146 * preceded by a 16-bit word with the leading and trailing cc
michael@0 147 * of the decomposition (like for A-umlaut);
michael@0 148 * if not, then both cc's are zero (like for compatibility ideographs).
michael@0 149 */
michael@0 150 _NORM_DECOMP_FLAG_LENGTH_HAS_CC=0x80,
michael@0 151 /**
michael@0 152 * Bits 6..0 of the length byte contain the actual length.
michael@0 153 */
michael@0 154 _NORM_DECOMP_LENGTH_MASK=0x7f
michael@0 155 };
michael@0 156
michael@0 157 /** Constants for options flags for normalization. */
michael@0 158 enum {
michael@0 159 /** Options bit 0, do not decompose Hangul syllables. */
michael@0 160 UNORM_NX_HANGUL=1,
michael@0 161 /** Options bit 1, do not decompose CJK compatibility characters. */
michael@0 162 UNORM_NX_CJK_COMPAT=2
michael@0 163 };
michael@0 164
michael@0 165 /**
michael@0 166 * Description of the format of unorm.icu version 2.3.
michael@0 167 *
michael@0 168 * Main change from version 1 to version 2:
michael@0 169 * Use of new, common UTrie instead of normalization-specific tries.
michael@0 170 * Change to version 2.1: add third/auxiliary trie with associated data.
michael@0 171 * Change to version 2.2: add skippable (f) flag data (_NORM_AUX_NFC_SKIP_F_MASK).
michael@0 172 * Change to version 2.3: add serialized sets for normalization exclusions
michael@0 173 * stored inside canonStartSets[]
michael@0 174 *
michael@0 175 * For more details of how to use the data structures see the code
michael@0 176 * in unorm.cpp (runtime normalization code) and
michael@0 177 * in gennorm.c and gennorm/store.c (build-time data generation).
michael@0 178 *
michael@0 179 * For the serialized format of UTrie see utrie.c/UTrieHeader.
michael@0 180 *
michael@0 181 * - Overall partition
michael@0 182 *
michael@0 183 * unorm.dat customarily begins with a UDataInfo structure, see udata.h and .c.
michael@0 184 * After that there are the following structures:
michael@0 185 *
michael@0 186 * int32_t indexes[_NORM_INDEX_TOP]; -- _NORM_INDEX_TOP=32, see enum in this file
michael@0 187 *
michael@0 188 * UTrie normTrie; -- size in bytes=indexes[_NORM_INDEX_TRIE_SIZE]
michael@0 189 *
michael@0 190 * uint16_t extraData[extraDataTop]; -- extraDataTop=indexes[_NORM_INDEX_UCHAR_COUNT]
michael@0 191 * extraData[0] contains the number of units for
michael@0 192 * FC_NFKC_Closure (formatVersion>=2.1)
michael@0 193 *
michael@0 194 * uint16_t combiningTable[combiningTableTop]; -- combiningTableTop=indexes[_NORM_INDEX_COMBINE_DATA_COUNT]
michael@0 195 * combiningTableTop may include one 16-bit padding unit
michael@0 196 * to make sure that fcdTrie is 32-bit-aligned
michael@0 197 *
michael@0 198 * UTrie fcdTrie; -- size in bytes=indexes[_NORM_INDEX_FCD_TRIE_SIZE]
michael@0 199 *
michael@0 200 * UTrie auxTrie; -- size in bytes=indexes[_NORM_INDEX_AUX_TRIE_SIZE]
michael@0 201 *
michael@0 202 * uint16_t canonStartSets[canonStartSetsTop] -- canonStartSetsTop=indexes[_NORM_INDEX_CANON_SET_COUNT]
michael@0 203 * serialized USets and binary search tables, see below
michael@0 204 *
michael@0 205 *
michael@0 206 * The indexes array contains lengths and sizes of the following arrays and structures
michael@0 207 * as well as the following values:
michael@0 208 * indexes[_NORM_INDEX_COMBINE_FWD_COUNT]=combineFwdTop
michael@0 209 * -- one more than the highest combining index computed for forward-only-combining characters
michael@0 210 * indexes[_NORM_INDEX_COMBINE_BOTH_COUNT]=combineBothTop-combineFwdTop
michael@0 211 * -- number of combining indexes computed for both-ways-combining characters
michael@0 212 * indexes[_NORM_INDEX_COMBINE_BACK_COUNT]=combineBackTop-combineBothTop
michael@0 213 * -- number of combining indexes computed for backward-only-combining characters
michael@0 214 *
michael@0 215 * indexes[_NORM_INDEX_MIN_NF*_NO_MAYBE] (where *={ C, D, KC, KD })
michael@0 216 * -- first code point with a quick check NF* value of NO/MAYBE
michael@0 217 *
michael@0 218 *
michael@0 219 * - Tries
michael@0 220 *
michael@0 221 * The main structures are two UTrie tables ("compact arrays"),
michael@0 222 * each with one index array and one data array.
michael@0 223 * See utrie.h and utrie.c.
michael@0 224 *
michael@0 225 *
michael@0 226 * - Tries in unorm.dat
michael@0 227 *
michael@0 228 * The first trie (normTrie above)
michael@0 229 * provides data for the NF* quick checks and normalization.
michael@0 230 * The second trie (fcdTrie above) provides data just for FCD checks.
michael@0 231 *
michael@0 232 *
michael@0 233 * - norm32 data words from the first trie
michael@0 234 *
michael@0 235 * The norm32Table contains one 32-bit word "norm32" per code point.
michael@0 236 * It contains the following bit fields:
michael@0 237 * 31..16 extra data index, _NORM_EXTRA_SHIFT is used to shift this field down
michael@0 238 * if this index is <_NORM_EXTRA_INDEX_TOP then it is an index into
michael@0 239 * extraData[] where variable-length normalization data for this
michael@0 240 * code point is found
michael@0 241 * if this index is <_NORM_EXTRA_INDEX_TOP+_NORM_EXTRA_SURROGATE_TOP
michael@0 242 * then this is a norm32 for a leading surrogate, and the index
michael@0 243 * value is used together with the following trailing surrogate
michael@0 244 * code unit in the second trie access
michael@0 245 * if this index is >=_NORM_EXTRA_INDEX_TOP+_NORM_EXTRA_SURROGATE_TOP
michael@0 246 * then this is a norm32 for a "special" character,
michael@0 247 * i.e., the character is a Hangul syllable or a Jamo
michael@0 248 * see _NORM_EXTRA_HANGUL etc.
michael@0 249 * generally, instead of extracting this index from the norm32 and
michael@0 250 * comparing it with the above constants,
michael@0 251 * the normalization code compares the entire norm32 value
michael@0 252 * with _NORM_MIN_SPECIAL, _NORM_SURROGATES_TOP, _NORM_MIN_HANGUL etc.
michael@0 253 *
michael@0 254 * 15..8 combining class (cc) according to UnicodeData.txt
michael@0 255 *
michael@0 256 * 7..6 _NORM_COMBINES_ANY flags, used in composition to see if a character
michael@0 257 * combines with any following or preceding character(s)
michael@0 258 * at all
michael@0 259 * 7 _NORM_COMBINES_BACK
michael@0 260 * 6 _NORM_COMBINES_FWD
michael@0 261 *
michael@0 262 * 5..0 quick check flags, set for "no" or "maybe", with separate flags for
michael@0 263 * each normalization form
michael@0 264 * the higher bits are "maybe" flags; for NF*D there are no such flags
michael@0 265 * the lower bits are "no" flags for all forms, in the same order
michael@0 266 * as the "maybe" flags,
michael@0 267 * which is (MSB to LSB): NFKD NFD NFKC NFC
michael@0 268 * 5..4 _NORM_QC_ANY_MAYBE
michael@0 269 * 3..0 _NORM_QC_ANY_NO
michael@0 270 * see further related constants
michael@0 271 *
michael@0 272 *
michael@0 273 * - Extra data per code point
michael@0 274 *
michael@0 275 * "Extra data" is referenced by the index in norm32.
michael@0 276 * It is variable-length data. It is only present, and only those parts
michael@0 277 * of it are, as needed for a given character.
michael@0 278 * The norm32 extra data index is added to the beginning of extraData[]
michael@0 279 * to get to a vector of 16-bit words with data at the following offsets:
michael@0 280 *
michael@0 281 * [-1] Combining index for composition.
michael@0 282 * Stored only if norm32&_NORM_COMBINES_ANY .
michael@0 283 * [0] Lengths of the canonical and compatibility decomposition strings.
michael@0 284 * Stored only if there are decompositions, i.e.,
michael@0 285 * if norm32&(_NORM_QC_NFD|_NORM_QC_NFKD)
michael@0 286 * High byte: length of NFKD, or 0 if none
michael@0 287 * Low byte: length of NFD, or 0 if none
michael@0 288 * Each length byte also has another flag:
michael@0 289 * Bit 7 of a length byte is set if there are non-zero
michael@0 290 * combining classes (cc's) associated with the respective
michael@0 291 * decomposition. If this flag is set, then the decomposition
michael@0 292 * is preceded by a 16-bit word that contains the
michael@0 293 * leading and trailing cc's.
michael@0 294 * Bits 6..0 of a length byte are the length of the
michael@0 295 * decomposition string, not counting the cc word.
michael@0 296 * [1..n] NFD
michael@0 297 * [n+1..] NFKD
michael@0 298 *
michael@0 299 * Each of the two decompositions consists of up to two parts:
michael@0 300 * - The 16-bit words with the leading and trailing cc's.
michael@0 301 * This is only stored if bit 7 of the corresponding length byte
michael@0 302 * is set. In this case, at least one of the cc's is not zero.
michael@0 303 * High byte: leading cc==cc of the first code point in the decomposition string
michael@0 304 * Low byte: trailing cc==cc of the last code point in the decomposition string
michael@0 305 * - The decomposition string in UTF-16, with length code units.
michael@0 306 *
michael@0 307 *
michael@0 308 * - Combining indexes and combiningTable[]
michael@0 309 *
michael@0 310 * Combining indexes are stored at the [-1] offset of the extra data
michael@0 311 * if the character combines forward or backward with any other characters.
michael@0 312 * They are used for (re)composition in NF*C.
michael@0 313 * Values of combining indexes are arranged according to whether a character
michael@0 314 * combines forward, backward, or both ways:
michael@0 315 * forward-only < both ways < backward-only
michael@0 316 *
michael@0 317 * The index values for forward-only and both-ways combining characters
michael@0 318 * are indexes into the combiningTable[].
michael@0 319 * The index values for backward-only combining characters are simply
michael@0 320 * incremented from the preceding index values to be unique.
michael@0 321 *
michael@0 322 * In the combiningTable[], a variable-length list
michael@0 323 * of variable-length (back-index, code point) pair entries is stored
michael@0 324 * for each forward-combining character.
michael@0 325 *
michael@0 326 * These back-indexes are the combining indexes of both-ways or backward-only
michael@0 327 * combining characters that the forward-combining character combines with.
michael@0 328 *
michael@0 329 * Each list is sorted in ascending order of back-indexes.
michael@0 330 * Each list is terminated with the last back-index having bit 15 set.
michael@0 331 *
michael@0 332 * Each pair (back-index, code point) takes up either 2 or 3
michael@0 333 * 16-bit words.
michael@0 334 * The first word of a list entry is the back-index, with its bit 15 set if
michael@0 335 * this is the last pair in the list.
michael@0 336 *
michael@0 337 * The second word contains flags in bits 15..13 that determine
michael@0 338 * if there is a third word and how the combined character is encoded:
michael@0 339 * 15 set if there is a third word in this list entry
michael@0 340 * 14 set if the result is a supplementary character
michael@0 341 * 13 set if the result itself combines forward
michael@0 342 *
michael@0 343 * According to these bits 15..14 of the second word,
michael@0 344 * the result character is encoded as follows:
michael@0 345 * 00 or 01 The result is <=0x1fff and stored in bits 12..0 of
michael@0 346 * the second word.
michael@0 347 * 10 The result is 0x2000..0xffff and stored in the third word.
michael@0 348 * Bits 12..0 of the second word are not used.
michael@0 349 * 11 The result is a supplementary character.
michael@0 350 * Bits 9..0 of the leading surrogate are in bits 9..0 of
michael@0 351 * the second word.
michael@0 352 * Add 0xd800 to these bits to get the complete surrogate.
michael@0 353 * Bits 12..10 of the second word are not used.
michael@0 354 * The trailing surrogate is stored in the third word.
michael@0 355 *
michael@0 356 *
michael@0 357 * - FCD trie
michael@0 358 *
michael@0 359 * The FCD trie is very simple.
michael@0 360 * It is a folded trie with 16-bit data words.
michael@0 361 * In each word, the high byte contains the leading cc of the character,
michael@0 362 * and the low byte contains the trailing cc of the character.
michael@0 363 * These cc's are the cc's of the first and last code points in the
michael@0 364 * canonical decomposition of the character.
michael@0 365 *
michael@0 366 * Since all 16 bits are used for cc's, lead surrogates must be tested
michael@0 367 * by checking the code unit instead of the trie data.
michael@0 368 * This is done only if the 16-bit data word is not zero.
michael@0 369 * If the code unit is a leading surrogate and the data word is not zero,
michael@0 370 * then instead of cc's it contains the offset for the second trie lookup.
michael@0 371 *
michael@0 372 *
michael@0 373 * - Auxiliary trie and data
michael@0 374 *
michael@0 375 * The auxiliary 16-bit trie contains data for additional properties.
michael@0 376 * Bits
michael@0 377 * 15..13 reserved
michael@0 378 * 12 not NFC_Skippable (f) (formatVersion>=2.2)
michael@0 379 * 11 flag: not a safe starter for canonical closure
michael@0 380 * 10 composition exclusion
michael@0 381 * 9.. 0 index into extraData[] to FC_NFKC_Closure string
michael@0 382 * (not for lead surrogate),
michael@0 383 * or lead surrogate offset (for lead surrogate, if 9..0 not zero)
michael@0 384 *
michael@0 385 * - FC_NFKC_Closure strings in extraData[]
michael@0 386 *
michael@0 387 * Strings are either stored as a single code unit or as the length
michael@0 388 * followed by that many units.
michael@0 389 * const UChar *s=extraData+(index from auxTrie data bits 9..0);
michael@0 390 * int32_t length;
michael@0 391 * if(*s<0xff00) {
michael@0 392 * // s points to the single-unit string
michael@0 393 * length=1;
michael@0 394 * } else {
michael@0 395 * length=*s&0xff;
michael@0 396 * ++s;
michael@0 397 * }
michael@0 398 *
michael@0 399 * Conditions for "NF* Skippable" from Mark Davis' com.ibm.text.UCD.NFSkippable:
michael@0 400 * (used in NormalizerTransliterator)
michael@0 401 *
michael@0 402 * A skippable character is
michael@0 403 * a) unassigned, or ALL of the following:
michael@0 404 * b) of combining class 0.
michael@0 405 * c) not decomposed by this normalization form.
michael@0 406 * AND if NFC or NFKC,
michael@0 407 * d) can never compose with a previous character.
michael@0 408 * e) can never compose with a following character.
michael@0 409 * f) can never change if another character is added.
michael@0 410 * Example: a-breve might satisfy all but f, but if you
michael@0 411 * add an ogonek it changes to a-ogonek + breve
michael@0 412 *
michael@0 413 * a)..e) must be tested from norm32.
michael@0 414 * Since f) is more complicated, the (not-)NFC_Skippable flag (f) is built
michael@0 415 * into the auxiliary trie.
michael@0 416 * The same bit is used for NFC and NFKC; (c) differs for them.
michael@0 417 * As usual, we build the "not skippable" flags so that unassigned
michael@0 418 * code points get a 0 bit.
michael@0 419 * This bit is only valid after (a)..(e) test FALSE; test NFD_NO before (f) as well.
michael@0 420 * Test Hangul LV syllables entirely in code.
michael@0 421 *
michael@0 422 *
michael@0 423 * - structure inside canonStartSets[]
michael@0 424 *
michael@0 425 * This array maps from code points c to sets of code points (USerializedSet).
michael@0 426 * The result sets are the code points whose canonical decompositions start
michael@0 427 * with c.
michael@0 428 *
michael@0 429 * canonStartSets[] contains the following sub-arrays:
michael@0 430 *
michael@0 431 * indexes[_NORM_SET_INDEX_TOP]
michael@0 432 * - contains lengths of sub-arrays etc.
michael@0 433 *
michael@0 434 * startSets[indexes[_NORM_SET_INDEX_CANON_SETS_LENGTH]-_NORM_SET_INDEX_TOP]
michael@0 435 * - contains serialized sets (USerializedSet) of canonical starters for
michael@0 436 * enumerating canonically equivalent strings
michael@0 437 * indexes[_NORM_SET_INDEX_CANON_SETS_LENGTH] includes _NORM_SET_INDEX_TOP
michael@0 438 * for details about the structure see uset.c
michael@0 439 *
michael@0 440 * bmpTable[indexes[_NORM_SET_INDEX_CANON_BMP_TABLE_LENGTH]]
michael@0 441 * - a sorted search table for BMP code points whose results are
michael@0 442 * either indexes to USerializedSets or single code points for
michael@0 443 * single-code point sets;
michael@0 444 * each entry is a pair of { code point, result } with result=(binary) yy xxxxxx xxxxxxxx
michael@0 445 * if yy==01 then there is a USerializedSet at canonStartSets+x
michael@0 446 * else build a USerializedSet with result as the single code point
michael@0 447 *
michael@0 448 * suppTable[indexes[_NORM_SET_INDEX_CANON_SUPP_TABLE_LENGTH]]
michael@0 449 * - a sorted search table for supplementary code points whose results are
michael@0 450 * either indexes to USerializedSets or single code points for
michael@0 451 * single-code point sets;
michael@0 452 * each entry is a triplet of { high16(cp), low16(cp), result }
michael@0 453 * each code point's high-word may contain extra data in bits 15..5:
michael@0 454 * if the high word has bit 15 set, then build a set with a single code point
michael@0 455 * which is (((high16(cp)&0x1f00)<<8)|result;
michael@0 456 * else there is a USerializedSet at canonStartSets+result
michael@0 457 *
michael@0 458 * FormatVersion 2.3 adds 2 serialized sets for normalization exclusions.
michael@0 459 * They are stored in the data file so that the runtime normalization code need
michael@0 460 * not depend on other properties and their data and implementation files.
michael@0 461 * The _NORM_SET_INDEX_NX_..._OFFSET offsets in the canonStartSets index table
michael@0 462 * give the location for each set.
michael@0 463 * There is no set stored for UNORM_NX_HANGUL because it's trivial to create
michael@0 464 * without using properties.
michael@0 465 *
michael@0 466 * Set contents:
michael@0 467 *
michael@0 468 * _NORM_SET_INDEX_NX_CJK_COMPAT_OFFSET (for UNORM_NX_CJK_COMPAT)
michael@0 469 * [[:Ideographic:]&[:NFD_QC=No:]]
michael@0 470 * =[CJK Ideographs]&[has canonical decomposition]
michael@0 471 *
michael@0 472 * _NORM_SET_INDEX_NX_UNICODE32_OFFSET (for UNORM_UNICODE_3_2)
michael@0 473 * [:^Age=3.2:]
michael@0 474 * =set with all code points that were not designated by the specified Unicode version
michael@0 475 *
michael@0 476 * _NORM_SET_INDEX_NX_RESERVED_OFFSET
michael@0 477 * This is an offset that points to where the next, future set would start.
michael@0 478 * Currently it indicates where the previous set ends, and thus its length.
michael@0 479 * The name for this enum constant may in the future be applied to different
michael@0 480 * index slots. In order to get the limit of a set, use its index slot and
michael@0 481 * the immediately following one regardless of that one's enum name.
michael@0 482 */
michael@0 483
michael@0 484 #endif /* #if !UCONFIG_NO_NORMALIZATION */
michael@0 485
michael@0 486 #endif

mercurial