2000-12-14 01:11:11 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
2013-09-13 19:25:01 +00:00
|
|
|
* Copyright (C) 1998-2013, International Business Machines
|
2000-12-14 01:11:11 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* Private implementation header for C collation
|
2001-03-08 17:40:42 +00:00
|
|
|
* file name: ucol_imp.h
|
2000-12-14 01:11:11 +00:00
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2000dec11
|
|
|
|
* created by: Vladimir Weinstein
|
2001-04-18 19:31:05 +00:00
|
|
|
*
|
2001-02-20 00:26:50 +00:00
|
|
|
* Modification history
|
|
|
|
* Date Name Comments
|
|
|
|
* 02/16/2001 synwee Added UCOL_GETPREVCE for the use in ucoleitr
|
2001-04-18 19:31:05 +00:00
|
|
|
* 02/27/2001 synwee Added getMaxExpansion data structure in UCollator
|
|
|
|
* 03/02/2001 synwee Added UCOL_IMPLICIT_CE
|
2001-03-12 20:05:46 +00:00
|
|
|
* 03/12/2001 synwee Added pointer start to collIterate.
|
2000-12-14 01:11:11 +00:00
|
|
|
*/
|
|
|
|
|
2000-12-12 19:44:23 +00:00
|
|
|
#ifndef UCOL_IMP_H
|
|
|
|
#define UCOL_IMP_H
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#include "unicode/utypes.h"
|
2011-07-27 05:53:56 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
# include "unicode/utf16.h"
|
|
|
|
#endif
|
2002-09-20 01:54:48 +00:00
|
|
|
|
2002-10-01 17:44:04 +00:00
|
|
|
#define UCA_DATA_TYPE "icu"
|
|
|
|
#define UCA_DATA_NAME "ucadata"
|
|
|
|
#define INVC_DATA_TYPE "icu"
|
|
|
|
#define INVC_DATA_NAME "invuca"
|
|
|
|
|
2004-04-14 19:58:08 +00:00
|
|
|
/**
|
|
|
|
* Convenience string denoting the Collation data tree
|
|
|
|
* @internal ICU 3.0
|
|
|
|
*/
|
|
|
|
#define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#if !UCONFIG_NO_COLLATION
|
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#ifdef __cplusplus
|
2010-01-06 23:50:03 +00:00
|
|
|
#include "unicode/normalizer2.h"
|
|
|
|
#include "unicode/unistr.h"
|
|
|
|
#endif
|
2000-12-12 19:44:23 +00:00
|
|
|
#include "unicode/ucol.h"
|
2011-07-03 04:07:02 +00:00
|
|
|
#include "ucol_data.h"
|
2001-12-19 07:00:45 +00:00
|
|
|
#include "utrie.h"
|
2008-06-09 21:18:46 +00:00
|
|
|
#include "cmemory.h"
|
2000-12-12 19:44:23 +00:00
|
|
|
|
2003-06-11 05:36:29 +00:00
|
|
|
/* This is the internal header file which contains important declarations for
|
|
|
|
* the collation framework.
|
|
|
|
* Ready to use collators are stored as binary images. Both UCA and tailorings
|
|
|
|
* share the same binary format. Individual files (currently only UCA) have a
|
|
|
|
* udata header in front of the image and should be opened using udata_open.
|
|
|
|
* Tailoring images are currently stored inside resource bundles and are intialized
|
|
|
|
* through ucol_open API.
|
2003-06-11 21:50:54 +00:00
|
|
|
*
|
|
|
|
* The following describes the formats for collation binaries
|
|
|
|
* (UCA & tailorings) and for the inverse UCA table.
|
|
|
|
* Substructures are described in the collation design document at
|
2007-06-11 19:14:47 +00:00
|
|
|
* http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm
|
2003-06-11 21:50:54 +00:00
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* -------------------------------------------------------------
|
|
|
|
*
|
2003-06-11 05:36:29 +00:00
|
|
|
* Here is the format of binary collation image.
|
2003-06-11 21:50:54 +00:00
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* Physical order of structures:
|
|
|
|
* - header (UCATableHeader)
|
|
|
|
* - options (UColOptionSet)
|
|
|
|
* - expansions (CE[])
|
|
|
|
* - contractions (UChar[contractionSize] + CE[contractionSize])
|
|
|
|
* - serialized UTrie with mappings of code points to CEs
|
|
|
|
* - max expansion tables (CE[endExpansionCECount] + uint8_t[endExpansionCECount])
|
|
|
|
* - two bit sets for backward processing in strcoll (identical prefixes)
|
|
|
|
* and for backward CE iteration (each set is uint8_t[UCOL_UNSAFECP_TABLE_SIZE])
|
|
|
|
* - UCA constants (UCAConstants)
|
|
|
|
* - UCA contractions (UChar[contractionUCACombosSize][contractionUCACombosWidth])
|
|
|
|
*
|
|
|
|
* UCATableHeader fields:
|
|
|
|
*
|
2003-06-11 05:36:29 +00:00
|
|
|
* int32_t size; - image size in bytes
|
2003-06-11 21:50:54 +00:00
|
|
|
*
|
2003-06-11 05:36:29 +00:00
|
|
|
* Offsets to interesting data. All offsets are in bytes.
|
|
|
|
* to get the address add to the header address and cast properly.
|
2003-09-12 18:50:01 +00:00
|
|
|
* Some offsets are zero if the corresponding structures are empty.
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
2003-09-18 23:17:43 +00:00
|
|
|
* Tailoring binaries that only set options and contain no mappings etc.
|
|
|
|
* will have all offsets 0 except for the options and expansion offsets,
|
|
|
|
* which give the position and length of the options array.
|
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t options; - offset to default collator options (UColOptionSet *),
|
|
|
|
* a set of 32-bit values. See declaration of UColOptionSet for more details
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t UCAConsts; - only used (!=0) in UCA image - structure which holds values for indirect positioning and implicit ranges
|
|
|
|
* See declaration of UCAConstants structure. This is a set of unsigned 32-bit values used to store
|
2003-06-11 19:31:44 +00:00
|
|
|
* important constant values that are defined in the UCA and used for building and runtime.
|
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t contractionUCACombos; - only used (!=0) in UCA image - list of UCA contractions. This is a zero terminated array of UChar[contractionUCACombosWidth],
|
2003-06-11 19:31:44 +00:00
|
|
|
* containing contractions from the UCA. These are needed in the build process to copy UCA contractions
|
|
|
|
* in case the base contraction symbol is tailored.
|
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t magic; - must contain UCOL_HEADER_MAGIC (formatVersion 2.3)
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
|
|
|
* uint32_t mappingPosition; - offset to UTrie (const uint8_t *mappingPosition). This is a serialized UTrie and should be treated as such.
|
|
|
|
* Used as a primary lookup table for collation elements.
|
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t expansion; - offset to expansion table (uint32_t *expansion). This is an array of expansion CEs. Never 0.
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
|
|
|
* uint32_t contractionIndex; - offset to contraction table (UChar *contractionIndex). Used to look up contraction sequences. Contents
|
2003-09-12 18:50:01 +00:00
|
|
|
* are aligned with the contents of contractionCEs table. 0 if no contractions.
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
|
|
|
* uint32_t contractionCEs; - offset to resulting contraction CEs (uint32_t *contractionCEs). When a contraction is resolved in the
|
|
|
|
* in the contractionIndex table, the resulting index is used to look up corresponding CE in this table.
|
2003-09-12 18:50:01 +00:00
|
|
|
* 0 if no contractions.
|
2003-06-11 19:31:44 +00:00
|
|
|
* uint32_t contractionSize; - size of contraction table in elements (both Index and CEs).
|
|
|
|
*
|
|
|
|
* Tables described below are used for Boyer-Moore searching algorithm - they define the size of longest expansion
|
|
|
|
* and last CEs in expansions.
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t endExpansionCE; - offset to array of last collation element in expansion (uint32_t *).
|
|
|
|
* Never 0.
|
2003-06-11 05:36:29 +00:00
|
|
|
* uint32_t expansionCESize; - array of maximum expansion sizes (uint8_t *)
|
2003-06-11 19:31:44 +00:00
|
|
|
* int32_t endExpansionCECount; - size of endExpansionCE. See UCOL_GETMAXEXPANSION
|
|
|
|
* for the usage model
|
|
|
|
*
|
|
|
|
* These two offsets point to byte tables that are used in the backup heuristics.
|
|
|
|
* uint32_t unsafeCP; - hash table of unsafe code points (uint8_t *). See ucol_unsafeCP function.
|
|
|
|
* uint32_t contrEndCP; - hash table of final code points in contractions (uint8_t *). See ucol_contractionEndCP.
|
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* int32_t contractionUCACombosSize; - number of UChar[contractionUCACombosWidth] in contractionUCACombos
|
|
|
|
* (formatVersion 2.3)
|
2003-06-11 19:31:44 +00:00
|
|
|
* UBool jamoSpecial; - Jamo special indicator (uint8_t). If TRUE, Jamos are special, so we cannot use simple Hangul decomposition.
|
2003-09-12 18:50:01 +00:00
|
|
|
* UBool isBigEndian; - endianness of this collation binary (formatVersion 2.3)
|
|
|
|
* uint8_t charSetFamily; - charset family of this collation binary (formatVersion 2.3)
|
|
|
|
* uint8_t contractionUCACombosWidth; - number of UChars per UCA contraction in contractionUCACombos (formatVersion 2.3)
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
|
|
|
* Various version fields
|
2003-06-11 05:36:29 +00:00
|
|
|
* UVersionInfo version; - version 4 uint8_t
|
|
|
|
* UVersionInfo UCAVersion; - version 4 uint8_t
|
|
|
|
* UVersionInfo UCDVersion; - version 4 uint8_t
|
2003-09-12 18:50:01 +00:00
|
|
|
* UVersionInfo formatVersion; - version of the format of the collation binary
|
|
|
|
* same formatVersion as in ucadata.icu's UDataInfo header
|
|
|
|
* (formatVersion 2.3)
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
2010-11-02 02:21:57 +00:00
|
|
|
* uint32_t offset to the reordering code to lead CE byte remapping table
|
|
|
|
* uint32_t offset to the lead CE byte to reordering code mapping table
|
|
|
|
*
|
|
|
|
* uint8_t reserved[76]; - currently unused
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
2003-09-12 18:50:01 +00:00
|
|
|
* -------------------------------------------------------------
|
2003-06-11 05:36:29 +00:00
|
|
|
*
|
|
|
|
* Inverse UCA is used for constructing collators from rules. It is always an individual file
|
|
|
|
* and always has a UDataInfo header.
|
|
|
|
* here is the structure:
|
|
|
|
*
|
|
|
|
* uint32_t byteSize; - size of inverse UCA image in bytes
|
2003-09-12 18:50:01 +00:00
|
|
|
* uint32_t tableSize; - length of inverse table (number of uint32_t[3] rows)
|
2003-06-11 05:36:29 +00:00
|
|
|
* uint32_t contsSize; - size of continuation table (number of UChars in table)
|
2003-06-11 19:31:44 +00:00
|
|
|
*
|
2003-06-11 05:36:29 +00:00
|
|
|
* uint32_t table; - offset to inverse table (uint32_t *)
|
2003-06-11 19:31:44 +00:00
|
|
|
* Inverse table contains of rows of 3 uint32_t values. First two values are CE and a possible continuation
|
|
|
|
* the third value is either a code unit (if there is only one code unit for element) or an index to continuation
|
|
|
|
* (number of code units combined with an index).
|
|
|
|
* table. If more than one codepoint have the same CE, continuation table contains code units separated by FFFF and final
|
|
|
|
* code unit sequence for a CE is terminated by FFFE.
|
|
|
|
* uint32_t conts; - offset to continuation table (uint16_t *). Contains code units that transform to a same CE.
|
|
|
|
*
|
2003-06-11 05:36:29 +00:00
|
|
|
* UVersionInfo UCAVersion; - version of the UCA, read from file 4 uint8_t
|
|
|
|
* uint8_t padding[8]; - padding 8 uint8_t
|
|
|
|
* Header is followed by the table and continuation table.
|
|
|
|
*/
|
|
|
|
|
2011-07-03 04:07:02 +00:00
|
|
|
/* definition of UCOL_HEADER_MAGIC moved to common/ucol_data.h */
|
2003-09-11 18:56:13 +00:00
|
|
|
|
2001-10-23 21:48:14 +00:00
|
|
|
/* UDataInfo for UCA mapping table */
|
2004-08-28 05:50:39 +00:00
|
|
|
/* dataFormat="UCol" */
|
|
|
|
#define UCA_DATA_FORMAT_0 ((uint8_t)0x55)
|
|
|
|
#define UCA_DATA_FORMAT_1 ((uint8_t)0x43)
|
|
|
|
#define UCA_DATA_FORMAT_2 ((uint8_t)0x6f)
|
|
|
|
#define UCA_DATA_FORMAT_3 ((uint8_t)0x6c)
|
2001-10-23 21:48:14 +00:00
|
|
|
|
2010-11-02 02:21:57 +00:00
|
|
|
#define UCA_FORMAT_VERSION_0 ((uint8_t)3)
|
2011-05-03 22:32:26 +00:00
|
|
|
#define UCA_FORMAT_VERSION_1 0
|
2004-08-28 05:50:39 +00:00
|
|
|
#define UCA_FORMAT_VERSION_2 ((uint8_t)0)
|
|
|
|
#define UCA_FORMAT_VERSION_3 ((uint8_t)0)
|
2001-10-23 21:48:14 +00:00
|
|
|
|
|
|
|
/* UDataInfo for inverse UCA table */
|
2004-08-28 05:50:39 +00:00
|
|
|
/* dataFormat="InvC" */
|
|
|
|
#define INVUCA_DATA_FORMAT_0 ((uint8_t)0x49)
|
|
|
|
#define INVUCA_DATA_FORMAT_1 ((uint8_t)0x6E)
|
|
|
|
#define INVUCA_DATA_FORMAT_2 ((uint8_t)0x76)
|
|
|
|
#define INVUCA_DATA_FORMAT_3 ((uint8_t)0x43)
|
|
|
|
|
|
|
|
#define INVUCA_FORMAT_VERSION_0 ((uint8_t)2)
|
|
|
|
#define INVUCA_FORMAT_VERSION_1 ((uint8_t)1)
|
|
|
|
#define INVUCA_FORMAT_VERSION_2 ((uint8_t)0)
|
|
|
|
#define INVUCA_FORMAT_VERSION_3 ((uint8_t)0)
|
2001-10-23 21:48:14 +00:00
|
|
|
|
2000-12-14 01:11:11 +00:00
|
|
|
/* This is the size of the stack allocated buffer for sortkey generation and similar operations */
|
|
|
|
/* if it is too small, heap allocation will occur.*/
|
|
|
|
/* you can change this value if you need memory - it will affect the performance, though, since we're going to malloc */
|
2001-03-16 20:01:24 +00:00
|
|
|
#define UCOL_MAX_BUFFER 128
|
2000-12-14 01:11:11 +00:00
|
|
|
|
|
|
|
#define UCOL_NORMALIZATION_GROWTH 2
|
2001-03-14 07:49:03 +00:00
|
|
|
#define UCOL_NORMALIZATION_MAX_BUFFER UCOL_MAX_BUFFER*UCOL_NORMALIZATION_GROWTH
|
2000-12-14 01:11:11 +00:00
|
|
|
|
|
|
|
/* This writable buffer is used if we encounter Thai and need to reorder the string on the fly */
|
|
|
|
/* Sometimes we already have a writable buffer (like in case of normalized strings). */
|
2001-04-18 19:31:05 +00:00
|
|
|
/*
|
2001-11-14 21:55:21 +00:00
|
|
|
you can change this value to any value >= 4 if you need memory -
|
2001-04-17 02:43:35 +00:00
|
|
|
it will affect the performance, though, since we're going to malloc.
|
2001-11-14 21:55:21 +00:00
|
|
|
Note 3 is the minimum value for Thai collation and 4 is the
|
|
|
|
minimum number for special Jamo
|
2001-04-17 02:43:35 +00:00
|
|
|
*/
|
2000-12-14 01:11:11 +00:00
|
|
|
#define UCOL_WRITABLE_BUFFER_SIZE 256
|
|
|
|
|
|
|
|
/* This is the size of the buffer for expansion CE's */
|
|
|
|
/* In reality we should not have to deal with expm sequences longer then 16 */
|
|
|
|
/* you can change this value if you need memory */
|
2007-12-26 19:38:01 +00:00
|
|
|
/* WARNING THIS BUFFER DOES HAVE MALLOC FALLBACK. If you make it too small, you'll get into performance trouble */
|
2000-12-14 01:11:11 +00:00
|
|
|
/* Reasonable small value is around 10, if you don't do Arabic or other funky collations that have long expansion sequence */
|
|
|
|
/* This is the longest expansion sequence we can handle without bombing out */
|
2007-12-26 19:34:45 +00:00
|
|
|
#define UCOL_EXPAND_CE_BUFFER_SIZE 64
|
2007-12-15 00:30:35 +00:00
|
|
|
|
|
|
|
/* This is the size to increase the buffer for expansion CE's */
|
|
|
|
#define UCOL_EXPAND_CE_BUFFER_EXTEND_SIZE 64
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2001-02-26 23:52:44 +00:00
|
|
|
|
2001-03-03 03:35:17 +00:00
|
|
|
/* Unsafe UChar hash table table size. */
|
|
|
|
/* size is 32 bytes for 1 bit for each latin 1 char + some power of two for */
|
|
|
|
/* hashing the rest of the chars. Size in bytes */
|
|
|
|
#define UCOL_UNSAFECP_TABLE_SIZE 1056
|
|
|
|
/* mask value down to "some power of two"-1 */
|
|
|
|
/* number of bits, not num of bytes. */
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_UNSAFECP_TABLE_MASK 0x1fff
|
2001-03-03 03:35:17 +00:00
|
|
|
|
|
|
|
|
2001-04-06 23:37:48 +00:00
|
|
|
/* flags bits for collIterate.flags */
|
|
|
|
/* */
|
2001-04-16 16:20:16 +00:00
|
|
|
/* NORM - set for incremental normalize of source string */
|
2001-04-06 23:37:48 +00:00
|
|
|
#define UCOL_ITER_NORM 1
|
|
|
|
|
|
|
|
#define UCOL_ITER_HASLEN 2
|
|
|
|
|
2001-04-18 19:31:05 +00:00
|
|
|
/* UCOL_ITER_INNORMBUF - set if the "pos" is in */
|
|
|
|
/* the writable side buffer, handling */
|
|
|
|
/* incrementally normalized characters. */
|
2001-04-06 23:37:48 +00:00
|
|
|
#define UCOL_ITER_INNORMBUF 4
|
|
|
|
|
2001-04-18 19:31:05 +00:00
|
|
|
/* UCOL_ITER_ALLOCATED - set if this iterator has */
|
|
|
|
/* malloced storage to expand a buffer. */
|
|
|
|
#define UCOL_ITER_ALLOCATED 8
|
2001-10-05 02:05:35 +00:00
|
|
|
/* UCOL_HIRAGANA_Q - note if the codepoint was hiragana */
|
|
|
|
#define UCOL_HIRAGANA_Q 16
|
|
|
|
/* UCOL_WAS_HIRAGANA - set to TRUE if there was a Hiragana */
|
|
|
|
/* otherwise set to false */
|
|
|
|
#define UCOL_WAS_HIRAGANA 32
|
2003-01-20 07:42:28 +00:00
|
|
|
/* UCOL_USE_ITERATOR - set this if collIterate uses a */
|
|
|
|
/* character iterator instead of simply accessing string */
|
|
|
|
/* by index */
|
|
|
|
#define UCOL_USE_ITERATOR 64
|
2001-04-18 19:31:05 +00:00
|
|
|
|
2009-01-22 00:24:48 +00:00
|
|
|
#define UCOL_FORCE_HAN_IMPLICIT 128
|
|
|
|
|
2001-04-06 23:37:48 +00:00
|
|
|
#define NFC_ZERO_CC_BLOCK_LIMIT_ 0x300
|
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#ifdef __cplusplus
|
2010-01-06 23:50:03 +00:00
|
|
|
|
2010-11-04 00:37:10 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
typedef struct collIterate : public UMemory {
|
2010-01-06 23:50:03 +00:00
|
|
|
const UChar *string; /* Original string */
|
2001-04-12 00:08:26 +00:00
|
|
|
/* UChar *start; Pointer to the start of the source string. Either points to string
|
2001-03-12 20:05:46 +00:00
|
|
|
or to writableBuffer */
|
2010-01-06 23:50:03 +00:00
|
|
|
const UChar *endp; /* string end ptr. Is undefined for null terminated strings */
|
|
|
|
const UChar *pos; /* This is position in the string. Can be to original or writable buf */
|
2001-04-06 23:37:48 +00:00
|
|
|
|
2000-12-14 18:03:26 +00:00
|
|
|
uint32_t *toReturn; /* This is the CE from CEs buffer that should be returned */
|
|
|
|
uint32_t *CEpos; /* This is the position to which we have stored processed CEs */
|
2008-05-23 04:22:28 +00:00
|
|
|
|
|
|
|
int32_t *offsetReturn; /* This is the offset to return, if non-NULL */
|
|
|
|
int32_t *offsetStore; /* This is the pointer for storing offsets */
|
|
|
|
int32_t offsetRepeatCount; /* Repeat stored offset if non-zero */
|
|
|
|
int32_t offsetRepeatValue; /* offset value to repeat */
|
|
|
|
|
2010-11-16 21:46:24 +00:00
|
|
|
UnicodeString writableBuffer;
|
2010-01-06 23:50:03 +00:00
|
|
|
const UChar *fcdPosition; /* Position in the original string to continue FCD check from. */
|
2001-03-09 00:50:37 +00:00
|
|
|
const UCollator *coll;
|
2010-11-16 21:46:24 +00:00
|
|
|
const Normalizer2 *nfd;
|
2001-04-06 23:37:48 +00:00
|
|
|
uint8_t flags;
|
2001-04-18 19:31:05 +00:00
|
|
|
uint8_t origFlags;
|
2007-12-15 00:30:35 +00:00
|
|
|
uint32_t *extendCEs; /* This is use if CEs is not big enough */
|
|
|
|
int32_t extendCEsSize; /* Holds the size of the dynamic CEs buffer */
|
2001-04-06 23:37:48 +00:00
|
|
|
uint32_t CEs[UCOL_EXPAND_CE_BUFFER_SIZE]; /* This is where we store CEs */
|
2008-05-23 04:22:28 +00:00
|
|
|
|
|
|
|
int32_t *offsetBuffer; /* A dynamic buffer to hold offsets */
|
|
|
|
int32_t offsetBufferSize; /* The size of the offset buffer */
|
|
|
|
|
2003-01-20 07:42:28 +00:00
|
|
|
UCharIterator *iterator;
|
|
|
|
/*int32_t iteratorIndex;*/
|
2010-10-19 21:48:04 +00:00
|
|
|
|
|
|
|
// The offsetBuffer should probably be a UVector32, but helper functions
|
|
|
|
// are an improvement over duplicated code.
|
|
|
|
void appendOffset(int32_t offset, UErrorCode &errorCode);
|
2005-01-09 06:18:07 +00:00
|
|
|
} collIterate;
|
2001-04-18 01:34:26 +00:00
|
|
|
|
2010-11-04 00:37:10 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
typedef struct collIterate collIterate;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-01-05 01:27:56 +00:00
|
|
|
#define paddedsize(something) ((something)+((((something)%4)!=0)?(4-(something)%4):0))
|
|
|
|
#define headersize (paddedsize(sizeof(UCATableHeader))+paddedsize(sizeof(UColOptionSet)))
|
|
|
|
|
2001-04-18 01:34:26 +00:00
|
|
|
/*
|
|
|
|
struct used internally in getSpecial*CE.
|
|
|
|
data similar to collIterate.
|
|
|
|
*/
|
|
|
|
struct collIterateState {
|
2010-01-06 23:50:03 +00:00
|
|
|
const UChar *pos; /* This is position in the string. Can be to original or writable buf */
|
|
|
|
const UChar *returnPos;
|
|
|
|
const UChar *fcdPosition; /* Position in the original string to continue FCD check from. */
|
|
|
|
const UChar *bufferaddress; /* address of the normalization buffer */
|
|
|
|
int32_t buffersize;
|
2001-04-20 22:29:53 +00:00
|
|
|
uint8_t flags;
|
|
|
|
uint8_t origFlags;
|
2003-01-23 01:52:34 +00:00
|
|
|
uint32_t iteratorIndex;
|
2003-02-06 23:29:56 +00:00
|
|
|
int32_t iteratorMove;
|
2001-04-18 01:34:26 +00:00
|
|
|
};
|
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
uprv_init_collIterate(const UCollator *collator,
|
|
|
|
const UChar *sourceString, int32_t sourceLen,
|
2010-11-16 21:46:24 +00:00
|
|
|
U_NAMESPACE_QUALIFIER collIterate *s, UErrorCode *status);
|
2010-01-06 23:50:03 +00:00
|
|
|
|
|
|
|
/* Internal functions for C test code. */
|
2010-11-16 21:46:24 +00:00
|
|
|
U_CAPI U_NAMESPACE_QUALIFIER collIterate * U_EXPORT2
|
2010-01-06 23:50:03 +00:00
|
|
|
uprv_new_collIterate(UErrorCode *status);
|
|
|
|
|
|
|
|
U_CAPI void U_EXPORT2
|
2010-11-16 21:46:24 +00:00
|
|
|
uprv_delete_collIterate(U_NAMESPACE_QUALIFIER collIterate *s);
|
2010-01-06 23:50:03 +00:00
|
|
|
|
|
|
|
/* @return s->pos == s->endp */
|
|
|
|
U_CAPI UBool U_EXPORT2
|
2010-11-16 21:46:24 +00:00
|
|
|
uprv_collIterateAtEnd(U_NAMESPACE_QUALIFIER collIterate *s);
|
2010-01-06 23:50:03 +00:00
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#ifdef __cplusplus
|
2001-04-06 23:37:48 +00:00
|
|
|
|
2008-06-06 21:51:25 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2008-05-23 04:22:28 +00:00
|
|
|
struct UCollationPCE;
|
|
|
|
typedef struct UCollationPCE UCollationPCE;
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2008-06-06 21:51:25 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2011-07-06 04:03:35 +00:00
|
|
|
struct UCollationElements : public icu::UMemory
|
2001-02-20 00:26:50 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Struct wrapper for source data
|
|
|
|
*/
|
2011-07-06 04:03:35 +00:00
|
|
|
icu::collIterate iteratordata_;
|
2001-02-20 00:26:50 +00:00
|
|
|
/**
|
2001-02-23 23:36:42 +00:00
|
|
|
* Indicates if this data has been reset.
|
|
|
|
*/
|
|
|
|
UBool reset_;
|
2001-04-06 23:37:48 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the data should be deleted.
|
|
|
|
*/
|
|
|
|
UBool isWritable;
|
2008-05-23 04:22:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data for getNextProcessed, getPreviousProcessed.
|
|
|
|
*/
|
2011-07-06 04:03:35 +00:00
|
|
|
icu::UCollationPCE *pce;
|
2001-02-20 00:26:50 +00:00
|
|
|
};
|
|
|
|
|
2010-05-25 22:17:12 +00:00
|
|
|
#else
|
|
|
|
/*opaque type*/
|
|
|
|
struct UCollationElements;
|
2010-01-21 23:28:30 +00:00
|
|
|
#endif
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2008-05-23 04:22:28 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
uprv_init_pce(const struct UCollationElements *elems);
|
|
|
|
|
2000-12-14 01:11:11 +00:00
|
|
|
#define UCOL_LEVELTERMINATOR 1
|
2001-01-16 00:28:40 +00:00
|
|
|
|
|
|
|
/* mask off anything but primary order */
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_PRIMARYORDERMASK 0xffff0000
|
2001-01-16 00:28:40 +00:00
|
|
|
/* mask off anything but secondary order */
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_SECONDARYORDERMASK 0x0000ff00
|
2001-01-16 00:28:40 +00:00
|
|
|
/* mask off anything but tertiary order */
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_TERTIARYORDERMASK 0x000000ff
|
2000-12-14 18:03:26 +00:00
|
|
|
/* primary order shift */
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_PRIMARYORDERSHIFT 16
|
2000-12-14 18:03:26 +00:00
|
|
|
/* secondary order shift */
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_SECONDARYORDERSHIFT 8
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_BYTE_SIZE_MASK 0xFF
|
2001-03-14 07:49:03 +00:00
|
|
|
|
|
|
|
#define UCOL_CASE_BYTE_START 0x80
|
|
|
|
#define UCOL_CASE_SHIFT_START 7
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2001-01-16 00:28:40 +00:00
|
|
|
#define UCOL_IGNORABLE 0
|
2001-03-03 04:06:43 +00:00
|
|
|
|
2000-12-14 01:11:11 +00:00
|
|
|
/* get weights from a CE */
|
2001-03-13 07:29:58 +00:00
|
|
|
#define UCOL_PRIMARYORDER(order) (((order) & UCOL_PRIMARYORDERMASK)>> UCOL_PRIMARYORDERSHIFT)
|
|
|
|
#define UCOL_SECONDARYORDER(order) (((order) & UCOL_SECONDARYORDERMASK)>> UCOL_SECONDARYORDERSHIFT)
|
|
|
|
#define UCOL_TERTIARYORDER(order) ((order) & UCOL_TERTIARYORDERMASK)
|
2000-12-14 01:11:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a character is a Thai vowel (which sorts after
|
|
|
|
* its base consonant).
|
|
|
|
*/
|
2001-03-13 07:29:58 +00:00
|
|
|
#define UCOL_ISTHAIPREVOWEL(ch) ((((uint32_t)(ch) - 0xe40) <= (0xe44 - 0xe40)) || \
|
|
|
|
(((uint32_t)(ch) - 0xec0) <= (0xec4 - 0xec0)))
|
2000-12-14 01:11:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a character is a Thai base consonant
|
|
|
|
*/
|
|
|
|
#define UCOL_ISTHAIBASECONSONANT(ch) ((uint32_t)(ch) - 0xe01) <= (0xe2e - 0xe01)
|
|
|
|
|
2001-03-08 00:58:36 +00:00
|
|
|
#define UCOL_ISJAMO(ch) ((((uint32_t)(ch) - 0x1100) <= (0x1112 - 0x1100)) || \
|
2001-03-13 07:29:58 +00:00
|
|
|
(((uint32_t)(ch) - 0x1161) <= (0x1175 - 0x1161)) || \
|
|
|
|
(((uint32_t)(ch) - 0x11A8) <= (0x11C2 - 0x11A8)))
|
2001-03-08 00:58:36 +00:00
|
|
|
|
2009-01-22 00:24:48 +00:00
|
|
|
/* Han character ranges */
|
|
|
|
#define UCOL_FIRST_HAN 0x4E00
|
|
|
|
#define UCOL_LAST_HAN 0x9FFF
|
|
|
|
#define UCOL_FIRST_HAN_A 0x3400
|
|
|
|
#define UCOL_LAST_HAN_A 0x4DBF
|
|
|
|
#define UCOL_FIRST_HAN_COMPAT 0xFAE0
|
|
|
|
#define UCOL_LAST_HAN_COMPAT 0xFA2F
|
|
|
|
|
|
|
|
/* Han extension B is in plane 2 */
|
2009-02-19 23:06:03 +00:00
|
|
|
#define UCOL_FIRST_HAN_B 0x20000
|
|
|
|
#define UCOL_LAST_HAN_B 0x2A6DF
|
2009-01-22 00:24:48 +00:00
|
|
|
|
|
|
|
/* Hangul range */
|
|
|
|
#define UCOL_FIRST_HANGUL 0xAC00
|
|
|
|
#define UCOL_LAST_HANGUL 0xD7AF
|
|
|
|
|
|
|
|
/* Jamo ranges */
|
|
|
|
#define UCOL_FIRST_L_JAMO 0x1100
|
|
|
|
#define UCOL_FIRST_V_JAMO 0x1161
|
|
|
|
#define UCOL_FIRST_T_JAMO 0x11A8
|
|
|
|
#define UCOL_LAST_T_JAMO 0x11F9
|
2001-03-08 00:58:36 +00:00
|
|
|
|
|
|
|
|
2001-04-06 23:37:48 +00:00
|
|
|
#if 0
|
2000-12-14 01:11:11 +00:00
|
|
|
/* initializes collIterate structure */
|
|
|
|
/* made as macro to speed up things */
|
2001-04-06 23:37:48 +00:00
|
|
|
#define init_collIterate(collator, sourceString, sourceLen, s) { \
|
2001-03-12 20:05:46 +00:00
|
|
|
(s)->start = (s)->string = (s)->pos = (UChar *)(sourceString); \
|
2001-04-06 23:37:48 +00:00
|
|
|
(s)->endp = (sourceLen) == -1 ? NULL :(UChar *)(sourceString)+(sourceLen); \
|
2000-12-14 01:11:11 +00:00
|
|
|
(s)->CEpos = (s)->toReturn = (s)->CEs; \
|
2001-04-06 23:37:48 +00:00
|
|
|
(s)->isThai = TRUE; \
|
|
|
|
(s)->writableBuffer = (s)->stackWritableBuffer; \
|
|
|
|
(s)->writableBufSize = UCOL_WRITABLE_BUFFER_SIZE; \
|
2001-03-09 00:50:37 +00:00
|
|
|
(s)->coll = (collator); \
|
2001-04-06 23:37:48 +00:00
|
|
|
(s)->fcdPosition = 0; \
|
|
|
|
(s)->flags = 0; \
|
|
|
|
if(((collator)->normalizationMode == UCOL_ON)) (s)->flags |= UCOL_ITER_NORM; \
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-12-14 01:11:11 +00:00
|
|
|
|
2001-04-18 19:31:05 +00:00
|
|
|
/*
|
2001-03-02 01:14:03 +00:00
|
|
|
* Macro to get the maximum size of an expansion ending with the argument ce.
|
|
|
|
* Used in the Boyer Moore algorithm.
|
2001-03-07 20:45:08 +00:00
|
|
|
* Note for tailoring, the UCA maxexpansion table has been merged.
|
|
|
|
* Hence we only have to search the tailored collator only.
|
2001-03-02 01:14:03 +00:00
|
|
|
* @param coll const UCollator pointer
|
|
|
|
* @param order last collation element of the expansion sequence
|
|
|
|
* @param result size of the longest expansion with argument collation element
|
|
|
|
* as the last element
|
|
|
|
*/
|
2001-06-12 17:37:36 +00:00
|
|
|
#define UCOL_GETMAXEXPANSION(coll, order, result) { \
|
2001-03-02 01:14:03 +00:00
|
|
|
const uint32_t *start; \
|
|
|
|
const uint32_t *limit; \
|
|
|
|
const uint32_t *mid; \
|
|
|
|
start = (coll)->endExpansionCE; \
|
|
|
|
limit = (coll)->lastEndExpansionCE; \
|
|
|
|
while (start < limit - 1) { \
|
|
|
|
mid = start + ((limit - start) >> 1); \
|
|
|
|
if ((order) <= *mid) { \
|
|
|
|
limit = mid; \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
start = mid; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
if (*start == order) { \
|
|
|
|
result = *((coll)->expansionCESize + (start - (coll)->endExpansionCE)); \
|
|
|
|
} \
|
2001-03-03 04:06:43 +00:00
|
|
|
else if (*limit == order) { \
|
|
|
|
result = *(coll->expansionCESize + (limit - coll->endExpansionCE)); \
|
|
|
|
} \
|
2001-06-12 17:37:36 +00:00
|
|
|
else if ((order & 0xFFFF) == 0x00C0) { \
|
2001-03-03 04:06:43 +00:00
|
|
|
result = 2; \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
result = 1; \
|
|
|
|
} \
|
2001-03-02 01:14:03 +00:00
|
|
|
}
|
|
|
|
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2010-11-16 21:46:24 +00:00
|
|
|
uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE,
|
|
|
|
U_NAMESPACE_QUALIFIER collIterate *source, UErrorCode *status);
|
2001-10-20 01:09:31 +00:00
|
|
|
|
|
|
|
U_CFUNC
|
|
|
|
uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
|
2010-11-16 21:46:24 +00:00
|
|
|
U_NAMESPACE_QUALIFIER collIterate *source, UErrorCode *status);
|
|
|
|
U_CAPI uint32_t U_EXPORT2 ucol_getNextCE(const UCollator *coll,
|
|
|
|
U_NAMESPACE_QUALIFIER collIterate *collationSource, UErrorCode *status);
|
2007-06-03 06:08:46 +00:00
|
|
|
U_CFUNC uint32_t U_EXPORT2 ucol_getPrevCE(const UCollator *coll,
|
2010-11-16 21:46:24 +00:00
|
|
|
U_NAMESPACE_QUALIFIER collIterate *collationSource,
|
|
|
|
UErrorCode *status);
|
2011-05-03 00:29:45 +00:00
|
|
|
/* get some memory */
|
|
|
|
void *ucol_getABuffer(const UCollator *coll, uint32_t size);
|
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#ifdef __cplusplus
|
2011-05-03 00:29:45 +00:00
|
|
|
|
2011-05-09 23:31:44 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2012-09-19 23:41:47 +00:00
|
|
|
class CollationKey;
|
2011-05-03 00:29:45 +00:00
|
|
|
class SortKeyByteSink;
|
|
|
|
|
2011-05-09 23:31:44 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2000-12-14 01:11:11 +00:00
|
|
|
/* function used by C++ getCollationKey to prevent restarting the calculation */
|
2001-09-27 01:01:30 +00:00
|
|
|
U_CFUNC int32_t
|
2012-09-19 23:41:47 +00:00
|
|
|
ucol_getCollationKey(const UCollator *coll,
|
|
|
|
const UChar *source, int32_t sourceLength,
|
|
|
|
icu::CollationKey &key,
|
|
|
|
UErrorCode &errorCode);
|
2000-12-12 19:44:23 +00:00
|
|
|
|
2011-05-03 00:29:45 +00:00
|
|
|
typedef void U_CALLCONV
|
|
|
|
SortKeyGenerator(const UCollator *coll,
|
|
|
|
const UChar *source,
|
|
|
|
int32_t sourceLength,
|
2011-07-06 04:03:35 +00:00
|
|
|
icu::SortKeyByteSink &result,
|
2011-05-03 00:29:45 +00:00
|
|
|
UErrorCode *status);
|
2000-12-14 01:11:11 +00:00
|
|
|
|
|
|
|
/* worker function for generating sortkeys */
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2011-05-03 00:29:45 +00:00
|
|
|
void U_CALLCONV
|
2000-12-12 19:44:23 +00:00
|
|
|
ucol_calcSortKey(const UCollator *coll,
|
|
|
|
const UChar *source,
|
|
|
|
int32_t sourceLength,
|
2011-07-06 04:03:35 +00:00
|
|
|
icu::SortKeyByteSink &result,
|
2001-01-15 07:28:54 +00:00
|
|
|
UErrorCode *status);
|
|
|
|
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2011-05-03 00:29:45 +00:00
|
|
|
void U_CALLCONV
|
2001-02-07 00:57:39 +00:00
|
|
|
ucol_calcSortKeySimpleTertiary(const UCollator *coll,
|
|
|
|
const UChar *source,
|
|
|
|
int32_t sourceLength,
|
2011-07-06 04:03:35 +00:00
|
|
|
icu::SortKeyByteSink &result,
|
2001-02-07 00:57:39 +00:00
|
|
|
UErrorCode *status);
|
2000-12-12 19:44:23 +00:00
|
|
|
|
2011-05-03 00:29:45 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
typedef void U_CALLCONV
|
|
|
|
SortKeyGenerator(const UCollator *coll,
|
|
|
|
const UChar *source,
|
|
|
|
int32_t sourceLength,
|
|
|
|
void *result,
|
|
|
|
UErrorCode *status);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2003-05-08 17:31:45 +00:00
|
|
|
/**
|
|
|
|
* Used to set requested and valid locales on a collator returned by the collator
|
|
|
|
* service.
|
|
|
|
*/
|
2007-06-03 06:08:46 +00:00
|
|
|
U_CFUNC void U_EXPORT2
|
2007-12-18 01:19:16 +00:00
|
|
|
ucol_setReqValidLocales(UCollator *coll, char *requestedLocaleToAdopt, char *validLocaleToAdopt, char *actualLocaleToAdopt);
|
2003-04-28 21:13:14 +00:00
|
|
|
|
2001-01-04 00:45:41 +00:00
|
|
|
#define UCOL_SPECIAL_FLAG 0xF0000000
|
|
|
|
#define UCOL_TAG_SHIFT 24
|
|
|
|
#define UCOL_TAG_MASK 0x0F000000
|
|
|
|
#define INIT_EXP_TABLE_SIZE 1024
|
|
|
|
#define UCOL_NOT_FOUND 0xF0000000
|
|
|
|
#define UCOL_EXPANSION 0xF1000000
|
|
|
|
#define UCOL_CONTRACTION 0xF2000000
|
|
|
|
#define UCOL_THAI 0xF3000000
|
2001-01-12 08:18:12 +00:00
|
|
|
#define UCOL_UNMARKED 0x03
|
2001-04-18 19:31:05 +00:00
|
|
|
#define UCOL_NEW_TERTIARYORDERMASK 0x0000003f
|
2001-01-04 00:45:41 +00:00
|
|
|
|
2001-01-15 19:02:30 +00:00
|
|
|
/* Bit mask for primary collation strength. */
|
|
|
|
#define UCOL_PRIMARYMASK 0xFFFF0000
|
|
|
|
|
|
|
|
/* Bit mask for secondary collation strength. */
|
|
|
|
#define UCOL_SECONDARYMASK 0x0000FF00
|
|
|
|
|
|
|
|
/* Bit mask for tertiary collation strength. */
|
|
|
|
#define UCOL_TERTIARYMASK 0x000000FF
|
|
|
|
|
2001-04-18 19:31:05 +00:00
|
|
|
/**
|
2001-02-22 23:16:06 +00:00
|
|
|
* Internal.
|
2001-04-18 19:31:05 +00:00
|
|
|
* This indicates the last element in a UCollationElements has been consumed.
|
2001-02-22 23:16:06 +00:00
|
|
|
* Compare with the UCOL_NULLORDER, UCOL_NULLORDER is returned if error occurs.
|
2001-01-15 19:02:30 +00:00
|
|
|
*/
|
2001-05-21 22:30:49 +00:00
|
|
|
#define UCOL_NO_MORE_CES 0x00010101
|
|
|
|
#define UCOL_NO_MORE_CES_PRIMARY 0x00010000
|
|
|
|
#define UCOL_NO_MORE_CES_SECONDARY 0x00000100
|
|
|
|
#define UCOL_NO_MORE_CES_TERTIARY 0x00000001
|
2001-01-15 19:02:30 +00:00
|
|
|
|
2001-01-04 00:45:41 +00:00
|
|
|
#define isSpecial(CE) ((((CE)&UCOL_SPECIAL_FLAG)>>28)==0xF)
|
2001-01-18 00:46:19 +00:00
|
|
|
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_UPPER_CASE 0x80
|
|
|
|
#define UCOL_MIXED_CASE 0x40
|
|
|
|
#define UCOL_LOWER_CASE 0x00
|
|
|
|
|
|
|
|
#define UCOL_CONTINUATION_MARKER 0xC0
|
|
|
|
#define UCOL_REMOVE_CONTINUATION 0xFFFFFF3F
|
|
|
|
|
|
|
|
#define isContinuation(CE) (((CE) & UCOL_CONTINUATION_MARKER) == UCOL_CONTINUATION_MARKER)
|
2001-01-25 06:51:18 +00:00
|
|
|
#define isFlagged(CE) (((CE) & 0x80) == 0x80)
|
|
|
|
#define isLongPrimary(CE) (((CE) & 0xC0) == 0xC0)
|
2001-01-18 00:46:19 +00:00
|
|
|
|
2001-01-04 00:45:41 +00:00
|
|
|
#define getCETag(CE) (((CE)&UCOL_TAG_MASK)>>UCOL_TAG_SHIFT)
|
2001-01-08 06:51:18 +00:00
|
|
|
#define isContraction(CE) (isSpecial((CE)) && (getCETag((CE)) == CONTRACTION_TAG))
|
2001-09-27 23:18:14 +00:00
|
|
|
#define isPrefix(CE) (isSpecial((CE)) && (getCETag((CE)) == SPEC_PROC_TAG))
|
2010-07-12 18:03:29 +00:00
|
|
|
#define constructContractCE(tag, CE) (UCOL_SPECIAL_FLAG | ((tag)<<UCOL_TAG_SHIFT) | ((CE)&0xFFFFFF))
|
|
|
|
#define constructSpecProcCE(CE) (UCOL_SPECIAL_FLAG | (SPEC_PROC_TAG<<UCOL_TAG_SHIFT) | ((CE)&0xFFFFFF))
|
2001-01-04 00:45:41 +00:00
|
|
|
#define getContractOffset(CE) ((CE)&0xFFFFFF)
|
2001-01-05 00:47:25 +00:00
|
|
|
#define getExpansionOffset(CE) (((CE)&0x00FFFFF0)>>4)
|
|
|
|
#define getExpansionCount(CE) ((CE)&0xF)
|
2001-03-02 00:19:43 +00:00
|
|
|
#define isCEIgnorable(CE) (((CE) & 0xFFFFFFBF) == 0)
|
|
|
|
|
2001-08-25 02:03:53 +00:00
|
|
|
/* StringSearch internal use */
|
|
|
|
#define inNormBuf(coleiter) ((coleiter)->iteratordata_.flags & UCOL_ITER_INNORMBUF)
|
|
|
|
#define isFCDPointerNull(coleiter) ((coleiter)->iteratordata_.fcdPosition == NULL)
|
2001-09-07 21:56:18 +00:00
|
|
|
#define hasExpansion(coleiter) ((coleiter)->iteratordata_.CEpos != (coleiter)->iteratordata_.CEs)
|
2001-08-25 02:03:53 +00:00
|
|
|
#define getExpansionPrefix(coleiter) ((coleiter)->iteratordata_.toReturn - (coleiter)->iteratordata_.CEs)
|
|
|
|
#define setExpansionPrefix(coleiter, offset) ((coleiter)->iteratordata_.CEs + offset)
|
|
|
|
#define getExpansionSuffix(coleiter) ((coleiter)->iteratordata_.CEpos - (coleiter)->iteratordata_.toReturn)
|
|
|
|
#define setExpansionSuffix(coleiter, offset) ((coleiter)->iteratordata_.toReturn = (coleiter)->iteratordata_.CEpos - leftoverces)
|
2001-01-18 00:46:19 +00:00
|
|
|
|
2010-10-19 21:48:04 +00:00
|
|
|
/* This is an enum that lists magic special byte values from the fractional UCA.
|
|
|
|
* See also http://site.icu-project.org/design/collation/bytes */
|
2001-04-23 23:35:59 +00:00
|
|
|
/* TODO: all the #defines that refer to special byte values from the UCA should be changed to point here */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
UCOL_BYTE_ZERO = 0x00,
|
|
|
|
UCOL_BYTE_LEVEL_SEPARATOR = 0x01,
|
|
|
|
UCOL_BYTE_SORTKEY_GLUE = 0x02,
|
|
|
|
UCOL_BYTE_SHIFT_PREFIX = 0x03,
|
|
|
|
UCOL_BYTE_UNSHIFTED_MIN = UCOL_BYTE_SHIFT_PREFIX,
|
|
|
|
UCOL_BYTE_FIRST_TAILORED = 0x04,
|
|
|
|
UCOL_BYTE_COMMON = 0x05,
|
|
|
|
UCOL_BYTE_FIRST_UCA = UCOL_BYTE_COMMON,
|
2010-10-19 21:48:04 +00:00
|
|
|
/* TODO: Make the following values dynamic since they change with almost every UCA version. */
|
|
|
|
UCOL_CODAN_PLACEHOLDER = 0x12,
|
|
|
|
UCOL_BYTE_FIRST_NON_LATIN_PRIMARY = 0x5B,
|
2001-04-23 23:35:59 +00:00
|
|
|
UCOL_BYTE_UNSHIFTED_MAX = 0xFF
|
|
|
|
};
|
|
|
|
|
2002-07-02 22:32:14 +00:00
|
|
|
#if 0
|
2002-03-15 23:41:56 +00:00
|
|
|
#define UCOL_RESET_TOP_VALUE 0x9F000303
|
|
|
|
#define UCOL_FIRST_PRIMARY_IGNORABLE 0x00008705
|
|
|
|
#define UCOL_LAST_PRIMARY_IGNORABLE 0x0000DD05
|
2002-06-13 18:33:19 +00:00
|
|
|
#define UCOL_LAST_PRIMARY_IGNORABLE_CONT 0x000051C0
|
2002-03-15 23:41:56 +00:00
|
|
|
#define UCOL_FIRST_SECONDARY_IGNORABLE 0x00000000
|
2002-03-26 16:46:17 +00:00
|
|
|
#define UCOL_LAST_SECONDARY_IGNORABLE 0x00000500
|
2002-03-15 23:41:56 +00:00
|
|
|
#define UCOL_FIRST_TERTIARY_IGNORABLE 0x00000000
|
|
|
|
#define UCOL_LAST_TERTIARY_IGNORABLE 0x00000000
|
|
|
|
#define UCOL_FIRST_VARIABLE 0x05070505
|
2002-06-13 18:33:19 +00:00
|
|
|
#define UCOL_LAST_VARIABLE 0x179B0505
|
|
|
|
#define UCOL_FIRST_NON_VARIABLE 0x1A200505
|
|
|
|
#define UCOL_LAST_NON_VARIABLE 0x7B41058F
|
2002-03-26 16:46:17 +00:00
|
|
|
|
|
|
|
#define UCOL_NEXT_TOP_VALUE 0xE8960303
|
|
|
|
#define UCOL_NEXT_FIRST_PRIMARY_IGNORABLE 0x00008905
|
|
|
|
#define UCOL_NEXT_LAST_PRIMARY_IGNORABLE 0x03000303
|
|
|
|
#define UCOL_NEXT_FIRST_SECONDARY_IGNORABLE 0x00008705
|
|
|
|
#define UCOL_NEXT_LAST_SECONDARY_IGNORABLE 0x00000500
|
|
|
|
#define UCOL_NEXT_FIRST_TERTIARY_IGNORABLE 0x00000000
|
|
|
|
#define UCOL_NEXT_LAST_TERTIARY_IGNORABLE 0x00000000
|
|
|
|
#define UCOL_NEXT_FIRST_VARIABLE 0x05090505
|
2002-06-13 18:33:19 +00:00
|
|
|
#define UCOL_NEXT_LAST_VARIABLE 0x1A200505
|
2002-03-15 23:41:56 +00:00
|
|
|
|
2001-05-18 18:09:53 +00:00
|
|
|
#define PRIMARY_IMPLICIT_MIN 0xE8000000
|
2001-05-17 23:14:44 +00:00
|
|
|
#define PRIMARY_IMPLICIT_MAX 0xF0000000
|
2002-07-02 22:32:14 +00:00
|
|
|
#endif
|
2001-04-23 23:35:59 +00:00
|
|
|
|
2001-04-19 20:29:34 +00:00
|
|
|
/* These constants can be changed - sortkey size is affected by them */
|
|
|
|
#define UCOL_PROPORTION2 0.5
|
2001-04-23 01:53:49 +00:00
|
|
|
#define UCOL_PROPORTION3 0.667
|
2001-04-19 20:29:34 +00:00
|
|
|
|
|
|
|
/* These values come from the UCA */
|
2001-04-23 23:35:59 +00:00
|
|
|
#define UCOL_COMMON_BOT2 UCOL_BYTE_COMMON
|
2001-10-30 01:43:05 +00:00
|
|
|
#define UCOL_COMMON_TOP2 0x86u
|
2001-04-19 20:29:34 +00:00
|
|
|
#define UCOL_TOTAL2 (UCOL_COMMON_TOP2-UCOL_COMMON_BOT2-1)
|
|
|
|
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_FLAG_BIT_MASK_CASE_SW_OFF 0x80
|
|
|
|
#define UCOL_FLAG_BIT_MASK_CASE_SW_ON 0x40
|
2001-09-21 21:22:44 +00:00
|
|
|
#define UCOL_COMMON_TOP3_CASE_SW_OFF 0x85
|
|
|
|
#define UCOL_COMMON_TOP3_CASE_SW_LOWER 0x45
|
|
|
|
#define UCOL_COMMON_TOP3_CASE_SW_UPPER 0xC5
|
2001-05-17 23:14:44 +00:00
|
|
|
|
2001-04-19 20:29:34 +00:00
|
|
|
/* These values come from the UCA */
|
|
|
|
#define UCOL_COMMON_BOT3 0x05
|
|
|
|
|
2001-05-17 23:14:44 +00:00
|
|
|
#define UCOL_COMMON_BOTTOM3_CASE_SW_UPPER 0x86;
|
|
|
|
#define UCOL_COMMON_BOTTOM3_CASE_SW_LOWER UCOL_COMMON_BOT3;
|
|
|
|
|
2001-04-19 20:29:34 +00:00
|
|
|
#define UCOL_TOP_COUNT2 (UCOL_PROPORTION2*UCOL_TOTAL2)
|
|
|
|
#define UCOL_BOT_COUNT2 (UCOL_TOTAL2-UCOL_TOP_COUNT2)
|
|
|
|
|
|
|
|
|
|
|
|
#define UCOL_COMMON2 UCOL_COMMON_BOT2
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_COMMON3_UPPERFIRST 0xC5
|
|
|
|
#define UCOL_COMMON3_NORMAL UCOL_COMMON_BOT3
|
2001-04-19 20:29:34 +00:00
|
|
|
|
2001-01-18 00:46:19 +00:00
|
|
|
#define UCOL_COMMON4 0xFF
|
2001-01-04 00:45:41 +00:00
|
|
|
|
2001-03-02 00:19:43 +00:00
|
|
|
/* constants for case level/case first handling */
|
|
|
|
/* used to instantiate UCollators fields in ucol_updateInternalState */
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_CASE_SWITCH 0xC0
|
2001-03-02 00:19:43 +00:00
|
|
|
#define UCOL_NO_CASE_SWITCH 0x00
|
|
|
|
|
|
|
|
#define UCOL_REMOVE_CASE 0x3F
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_KEEP_CASE 0xFF
|
2001-03-02 00:19:43 +00:00
|
|
|
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_CASE_BIT_MASK 0xC0
|
2001-03-02 00:19:43 +00:00
|
|
|
|
2001-05-10 22:33:50 +00:00
|
|
|
#define UCOL_TERT_CASE_MASK 0xFF
|
2001-03-02 00:19:43 +00:00
|
|
|
|
2002-09-04 06:02:13 +00:00
|
|
|
#define UCOL_ENDOFLATINONERANGE 0xFF
|
|
|
|
#define UCOL_LATINONETABLELEN (UCOL_ENDOFLATINONERANGE+50)
|
|
|
|
#define UCOL_BAIL_OUT_CE 0xFF000000
|
|
|
|
|
|
|
|
|
2001-01-05 00:47:25 +00:00
|
|
|
typedef enum {
|
|
|
|
NOT_FOUND_TAG = 0,
|
2001-09-20 20:16:39 +00:00
|
|
|
EXPANSION_TAG = 1, /* This code point results in an expansion */
|
|
|
|
CONTRACTION_TAG = 2, /* Start of a contraction */
|
|
|
|
THAI_TAG = 3, /* Thai character - do the reordering */
|
|
|
|
CHARSET_TAG = 4, /* Charset processing, not yet implemented */
|
|
|
|
SURROGATE_TAG = 5, /* Lead surrogate that is tailored and doesn't start a contraction */
|
|
|
|
HANGUL_SYLLABLE_TAG = 6, /* AC00-D7AF*/
|
|
|
|
LEAD_SURROGATE_TAG = 7, /* D800-DBFF*/
|
|
|
|
TRAIL_SURROGATE_TAG = 8, /* DC00-DFFF*/
|
|
|
|
CJK_IMPLICIT_TAG = 9, /* 0x3400-0x4DB5, 0x4E00-0x9FA5, 0xF900-0xFA2D*/
|
|
|
|
IMPLICIT_TAG = 10,
|
2001-09-27 23:18:14 +00:00
|
|
|
SPEC_PROC_TAG = 11,
|
2002-01-08 00:11:54 +00:00
|
|
|
/* ICU 2.1 */
|
|
|
|
LONG_PRIMARY_TAG = 12, /* This is a three byte primary with starting secondaries and tertiaries */
|
|
|
|
/* It fits in a single 32 bit CE and is used instead of expansion to save */
|
|
|
|
/* space without affecting the performance (hopefully) */
|
2003-07-25 05:31:54 +00:00
|
|
|
|
2004-11-11 23:34:58 +00:00
|
|
|
DIGIT_TAG = 13, /* COllate Digits As Numbers (CODAN) implementation */
|
|
|
|
|
2001-01-05 00:47:25 +00:00
|
|
|
CE_TAGS_COUNT
|
|
|
|
} UColCETags;
|
|
|
|
|
2001-09-20 20:16:39 +00:00
|
|
|
/*
|
|
|
|
*****************************************************************************************
|
|
|
|
* set to zero
|
|
|
|
* NON_CHARACTER FDD0 - FDEF, FFFE, FFFF, 1FFFE, 1FFFF, 2FFFE, 2FFFF,...e.g. **FFFE, **FFFF
|
|
|
|
******************************************************************************************
|
|
|
|
*/
|
|
|
|
|
2001-03-30 00:23:46 +00:00
|
|
|
typedef struct {
|
2001-06-26 22:24:10 +00:00
|
|
|
uint32_t variableTopValue;
|
2002-09-17 04:53:35 +00:00
|
|
|
/*UColAttributeValue*/ int32_t frenchCollation;
|
|
|
|
/*UColAttributeValue*/ int32_t alternateHandling; /* attribute for handling variable elements*/
|
|
|
|
/*UColAttributeValue*/ int32_t caseFirst; /* who goes first, lower case or uppercase */
|
|
|
|
/*UColAttributeValue*/ int32_t caseLevel; /* do we have an extra case level */
|
|
|
|
/*UColAttributeValue*/ int32_t normalizationMode; /* attribute for normalization */
|
|
|
|
/*UColAttributeValue*/ int32_t strength; /* attribute for strength */
|
2003-07-25 05:31:54 +00:00
|
|
|
/*UColAttributeValue*/ int32_t hiraganaQ; /* attribute for special Hiragana */
|
2003-09-10 20:57:06 +00:00
|
|
|
/*UColAttributeValue*/ int32_t numericCollation; /* attribute for numeric collation */
|
|
|
|
uint32_t reserved[15]; /* for future use */
|
2001-03-30 00:23:46 +00:00
|
|
|
} UColOptionSet;
|
2001-01-05 00:47:25 +00:00
|
|
|
|
2002-06-13 18:33:19 +00:00
|
|
|
typedef struct {
|
2002-07-02 22:32:14 +00:00
|
|
|
uint32_t UCA_FIRST_TERTIARY_IGNORABLE[2]; /*0x00000000*/
|
|
|
|
uint32_t UCA_LAST_TERTIARY_IGNORABLE[2]; /*0x00000000*/
|
|
|
|
uint32_t UCA_FIRST_PRIMARY_IGNORABLE[2]; /*0x00008705*/
|
|
|
|
uint32_t UCA_FIRST_SECONDARY_IGNORABLE[2]; /*0x00000000*/
|
|
|
|
uint32_t UCA_LAST_SECONDARY_IGNORABLE[2]; /*0x00000500*/
|
|
|
|
uint32_t UCA_LAST_PRIMARY_IGNORABLE[2]; /*0x0000DD05*/
|
|
|
|
uint32_t UCA_FIRST_VARIABLE[2]; /*0x05070505*/
|
|
|
|
uint32_t UCA_LAST_VARIABLE[2]; /*0x13CF0505*/
|
|
|
|
uint32_t UCA_FIRST_NON_VARIABLE[2]; /*0x16200505*/
|
|
|
|
uint32_t UCA_LAST_NON_VARIABLE[2]; /*0x767C0505*/
|
|
|
|
uint32_t UCA_RESET_TOP_VALUE[2]; /*0x9F000303*/
|
|
|
|
uint32_t UCA_FIRST_IMPLICIT[2];
|
|
|
|
uint32_t UCA_LAST_IMPLICIT[2];
|
|
|
|
uint32_t UCA_FIRST_TRAILING[2];
|
|
|
|
uint32_t UCA_LAST_TRAILING[2];
|
2002-06-13 18:33:19 +00:00
|
|
|
|
|
|
|
#if 0
|
2002-07-02 22:32:14 +00:00
|
|
|
uint32_t UCA_NEXT_TOP_VALUE[2]; /*0xE8960303*/
|
2002-06-13 18:33:19 +00:00
|
|
|
uint32_t UCA_NEXT_FIRST_PRIMARY_IGNORABLE; /*0x00008905*/
|
|
|
|
uint32_t UCA_NEXT_LAST_PRIMARY_IGNORABLE; /*0x03000303*/
|
|
|
|
uint32_t UCA_NEXT_FIRST_SECONDARY_IGNORABLE; /*0x00008705*/
|
|
|
|
uint32_t UCA_NEXT_LAST_SECONDARY_IGNORABLE; /*0x00000500*/
|
|
|
|
uint32_t UCA_NEXT_FIRST_TERTIARY_IGNORABLE; /*0x00000000*/
|
|
|
|
uint32_t UCA_NEXT_LAST_TERTIARY_IGNORABLE; /*0x00000000*/
|
|
|
|
uint32_t UCA_NEXT_FIRST_VARIABLE; /*0x05090505*/
|
|
|
|
uint32_t UCA_NEXT_LAST_VARIABLE; /*0x16200505*/
|
|
|
|
#endif
|
|
|
|
|
2002-07-02 22:32:14 +00:00
|
|
|
uint32_t UCA_PRIMARY_TOP_MIN;
|
2002-06-13 18:33:19 +00:00
|
|
|
uint32_t UCA_PRIMARY_IMPLICIT_MIN; /*0xE8000000*/
|
|
|
|
uint32_t UCA_PRIMARY_IMPLICIT_MAX; /*0xF0000000*/
|
2002-07-02 22:32:14 +00:00
|
|
|
uint32_t UCA_PRIMARY_TRAILING_MIN; /*0xE8000000*/
|
|
|
|
uint32_t UCA_PRIMARY_TRAILING_MAX; /*0xF0000000*/
|
|
|
|
uint32_t UCA_PRIMARY_SPECIAL_MIN; /*0xE8000000*/
|
|
|
|
uint32_t UCA_PRIMARY_SPECIAL_MAX; /*0xF0000000*/
|
2002-06-13 18:33:19 +00:00
|
|
|
} UCAConstants;
|
|
|
|
|
2011-07-03 04:07:02 +00:00
|
|
|
/* definition of UCATableHeader moved to common/ucol_data.h */
|
2001-01-04 00:45:41 +00:00
|
|
|
|
2001-07-06 04:57:28 +00:00
|
|
|
#define U_UNKNOWN_STATE 0
|
|
|
|
#define U_COLLATOR_STATE 0x01
|
|
|
|
#define U_STATE_LIMIT 0x02
|
2001-07-03 22:21:53 +00:00
|
|
|
|
|
|
|
/* This is the first structure in a state */
|
|
|
|
/* it should be machine independent */
|
|
|
|
typedef struct {
|
|
|
|
/* this structure is supposed to be readable on all the platforms.*/
|
|
|
|
/* first 2 fields hold the size of the structure in a platform independent way */
|
|
|
|
uint8_t sizeLo;
|
|
|
|
uint8_t sizeHi;
|
|
|
|
/* identifying the writing platform */
|
|
|
|
uint8_t isBigEndian;
|
|
|
|
/* see U_CHARSET_FAMILY values in utypes.h */
|
|
|
|
uint8_t charsetFamily;
|
|
|
|
/* version of ICU this state structure comes from */
|
|
|
|
uint8_t icuVersion[4];
|
2001-07-06 04:57:28 +00:00
|
|
|
/* What is the data following this state */
|
|
|
|
uint8_t type;
|
|
|
|
/* more stuff to come, keep it on 16 byte boundary */
|
|
|
|
uint8_t reserved[7];
|
2001-07-09 22:24:23 +00:00
|
|
|
} UStateStruct;
|
2001-07-03 22:21:53 +00:00
|
|
|
|
|
|
|
/* This structure follows UStatusStruct */
|
|
|
|
/* and contains data specific for the collators */
|
|
|
|
/* Endianess needs to be decided before accessing this structure */
|
|
|
|
/* However, it's size IS endianess independent */
|
|
|
|
typedef struct {
|
|
|
|
/* size of this structure */
|
|
|
|
uint8_t sizeLo;
|
|
|
|
uint8_t sizeHi;
|
2001-07-06 04:57:28 +00:00
|
|
|
/* This state is followed by the frozen tailoring */
|
|
|
|
uint8_t containsTailoring;
|
|
|
|
/* This state is followed by the frozen UCA */
|
|
|
|
uint8_t containsUCA;
|
|
|
|
/* Version info - the same one */
|
|
|
|
uint8_t versionInfo[4];
|
|
|
|
|
|
|
|
/* for charset CEs */
|
|
|
|
uint8_t charsetName[32];
|
|
|
|
/* this is the resolved locale name*/
|
|
|
|
uint8_t locale[32];
|
|
|
|
|
|
|
|
/* Attributes. Open ended */
|
|
|
|
/* all the following will be moved to uint32_t because of portability */
|
|
|
|
/* variable top value */
|
2001-07-03 22:21:53 +00:00
|
|
|
uint32_t variableTopValue;
|
2001-07-06 04:57:28 +00:00
|
|
|
/* attribute for handling variable elements*/
|
|
|
|
uint32_t /*UColAttributeValue*/ alternateHandling;
|
|
|
|
/* how to handle secondary weights */
|
|
|
|
uint32_t /*UColAttributeValue*/ frenchCollation;
|
|
|
|
/* who goes first, lower case or uppercase */
|
|
|
|
uint32_t /*UColAttributeValue*/ caseFirst;
|
|
|
|
/* do we have an extra case level */
|
|
|
|
uint32_t /*UColAttributeValue*/ caseLevel;
|
|
|
|
/* attribute for normalization */
|
|
|
|
uint32_t /*UColAttributeValue*/ normalizationMode;
|
|
|
|
/* attribute for strength */
|
|
|
|
uint32_t /*UColAttributeValue*/ strength;
|
|
|
|
/* to be immediately 16 byte aligned */
|
|
|
|
uint8_t reserved[12];
|
2001-07-09 22:24:23 +00:00
|
|
|
} UColStateStruct;
|
2001-07-03 22:21:53 +00:00
|
|
|
|
2001-05-02 05:05:06 +00:00
|
|
|
#define UCOL_INV_SIZEMASK 0xFFF00000
|
|
|
|
#define UCOL_INV_OFFSETMASK 0x000FFFFF
|
|
|
|
#define UCOL_INV_SHIFTVALUE 20
|
|
|
|
|
2001-10-31 21:54:44 +00:00
|
|
|
U_CDECL_BEGIN
|
|
|
|
|
2011-07-03 04:07:02 +00:00
|
|
|
/* definition of InverseUCATableHeader moved to common/ucol_data.h */
|
2001-01-31 07:20:56 +00:00
|
|
|
|
2005-07-07 22:12:43 +00:00
|
|
|
typedef void U_CALLCONV
|
|
|
|
ResourceCleaner(UCollator *coll);
|
|
|
|
|
|
|
|
|
2001-01-15 07:28:54 +00:00
|
|
|
struct UCollator {
|
2002-08-06 00:55:25 +00:00
|
|
|
UColOptionSet *options;
|
2001-03-14 02:45:39 +00:00
|
|
|
SortKeyGenerator *sortKeyGen;
|
2002-09-04 06:02:13 +00:00
|
|
|
uint32_t *latinOneCEs;
|
2007-12-18 01:19:16 +00:00
|
|
|
char* actualLocale;
|
2003-04-28 21:13:14 +00:00
|
|
|
char* validLocale;
|
2002-03-13 05:48:25 +00:00
|
|
|
char* requestedLocale;
|
2006-05-15 05:08:49 +00:00
|
|
|
const UChar *rules;
|
2007-12-18 01:19:16 +00:00
|
|
|
const UChar *ucaRules;
|
2006-05-15 05:08:49 +00:00
|
|
|
const UCollator *UCA;
|
2001-01-04 00:45:41 +00:00
|
|
|
const UCATableHeader *image;
|
2006-05-21 01:27:15 +00:00
|
|
|
UTrie mapping;
|
2001-01-04 00:45:41 +00:00
|
|
|
const uint32_t *latinOneMapping;
|
2001-04-18 19:31:05 +00:00
|
|
|
const uint32_t *expansion;
|
2002-08-06 00:55:25 +00:00
|
|
|
const UChar *contractionIndex;
|
2001-04-18 19:31:05 +00:00
|
|
|
const uint32_t *contractionCEs;
|
2002-08-06 00:55:25 +00:00
|
|
|
|
|
|
|
const uint32_t *endExpansionCE; /* array of last ces in an expansion ce.
|
|
|
|
corresponds to expansionCESize */
|
|
|
|
const uint32_t *lastEndExpansionCE;/* pointer to the last element in endExpansionCE */
|
|
|
|
const uint8_t *expansionCESize; /* array of the maximum size of a
|
|
|
|
expansion ce with the last ce
|
|
|
|
corresponding to endExpansionCE,
|
|
|
|
terminated with a null */
|
|
|
|
const uint8_t *unsafeCP; /* unsafe code points hashtable */
|
|
|
|
const uint8_t *contrEndCP; /* Contraction ending chars hash table */
|
|
|
|
UChar minUnsafeCP; /* Smallest unsafe Code Point. */
|
|
|
|
UChar minContrEndCP; /* Smallest code point at end of a contraction */
|
|
|
|
|
|
|
|
int32_t rulesLength;
|
2002-09-04 06:02:13 +00:00
|
|
|
int32_t latinOneTableLen;
|
2002-08-06 00:55:25 +00:00
|
|
|
|
2001-06-26 22:24:10 +00:00
|
|
|
uint32_t variableTopValue;
|
2001-01-04 00:45:41 +00:00
|
|
|
UColAttributeValue frenchCollation;
|
|
|
|
UColAttributeValue alternateHandling; /* attribute for handling variable elements*/
|
|
|
|
UColAttributeValue caseFirst; /* who goes first, lower case or uppercase */
|
|
|
|
UColAttributeValue caseLevel; /* do we have an extra case level */
|
|
|
|
UColAttributeValue normalizationMode; /* attribute for normalization */
|
|
|
|
UColAttributeValue strength; /* attribute for strength */
|
2001-10-02 16:49:57 +00:00
|
|
|
UColAttributeValue hiraganaQ; /* attribute for Hiragana */
|
2003-07-25 05:31:54 +00:00
|
|
|
UColAttributeValue numericCollation;
|
2001-01-09 00:52:18 +00:00
|
|
|
UBool variableTopValueisDefault;
|
|
|
|
UBool frenchCollationisDefault;
|
|
|
|
UBool alternateHandlingisDefault; /* attribute for handling variable elements*/
|
|
|
|
UBool caseFirstisDefault; /* who goes first, lower case or uppercase */
|
|
|
|
UBool caseLevelisDefault; /* do we have an extra case level */
|
|
|
|
UBool normalizationModeisDefault; /* attribute for normalization */
|
|
|
|
UBool strengthisDefault; /* attribute for strength */
|
2001-10-02 16:49:57 +00:00
|
|
|
UBool hiraganaQisDefault; /* attribute for Hiragana */
|
2003-07-25 05:31:54 +00:00
|
|
|
UBool numericCollationisDefault;
|
2001-02-26 10:28:56 +00:00
|
|
|
UBool hasRealData; /* some collators have only options, like French, no rules */
|
|
|
|
/* to speed up things, we use the UCA image, but we don't want it */
|
|
|
|
/* to run around */
|
2002-08-06 00:55:25 +00:00
|
|
|
|
|
|
|
UBool freeOnClose;
|
|
|
|
UBool freeOptionsOnClose;
|
2001-03-03 09:27:42 +00:00
|
|
|
UBool freeRulesOnClose;
|
2003-05-06 07:28:34 +00:00
|
|
|
UBool freeImageOnClose;
|
2011-04-12 18:23:27 +00:00
|
|
|
UBool freeDefaultReorderCodesOnClose;
|
|
|
|
UBool freeReorderCodesOnClose;
|
|
|
|
UBool freeLeadBytePermutationTableOnClose;
|
2001-09-27 01:01:30 +00:00
|
|
|
|
2002-09-04 06:02:13 +00:00
|
|
|
UBool latinOneUse;
|
|
|
|
UBool latinOneRegenTable;
|
|
|
|
UBool latinOneFailed;
|
|
|
|
|
2007-12-18 01:19:16 +00:00
|
|
|
int8_t tertiaryAddition; /* when switching case, we need to add or subtract different values */
|
2002-08-06 00:55:25 +00:00
|
|
|
uint8_t caseSwitch;
|
|
|
|
uint8_t tertiaryCommon;
|
|
|
|
uint8_t tertiaryMask;
|
|
|
|
uint8_t tertiaryTop; /* Upper range when compressing */
|
|
|
|
uint8_t tertiaryBottom; /* Upper range when compressing */
|
|
|
|
uint8_t tertiaryTopCount;
|
|
|
|
uint8_t tertiaryBottomCount;
|
|
|
|
|
2006-05-15 05:08:49 +00:00
|
|
|
UVersionInfo dataVersion; /* Data info of UCA table */
|
2011-03-18 22:52:30 +00:00
|
|
|
int32_t* defaultReorderCodes;
|
|
|
|
int32_t defaultReorderCodesLength;
|
2010-11-03 02:41:22 +00:00
|
|
|
int32_t* reorderCodes;
|
2010-11-04 20:12:39 +00:00
|
|
|
int32_t reorderCodesLength;
|
2010-11-03 02:41:22 +00:00
|
|
|
uint8_t* leadBytePermutationTable;
|
2012-02-18 23:10:51 +00:00
|
|
|
void *delegate; /* if non-null: C++ object to delegate all API calls to. */
|
2001-01-04 00:45:41 +00:00
|
|
|
};
|
|
|
|
|
2001-10-31 21:54:44 +00:00
|
|
|
U_CDECL_END
|
|
|
|
|
2001-01-16 00:28:40 +00:00
|
|
|
/* various internal functions */
|
2001-10-20 01:09:31 +00:00
|
|
|
|
2003-04-30 00:49:01 +00:00
|
|
|
/* do not close UCA returned by ucol_initUCA! */
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2003-04-30 00:49:01 +00:00
|
|
|
UCollator* ucol_initUCA(UErrorCode *status);
|
2001-02-26 10:28:56 +00:00
|
|
|
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2003-09-24 00:17:15 +00:00
|
|
|
UCollator* ucol_initCollator(const UCATableHeader *image, UCollator *fillIn, const UCollator *UCA, UErrorCode *status);
|
2001-10-20 01:09:31 +00:00
|
|
|
|
|
|
|
U_CFUNC
|
2001-03-30 00:23:46 +00:00
|
|
|
void ucol_setOptionsFromHeader(UCollator* result, UColOptionSet * opts, UErrorCode *status);
|
2001-10-20 01:09:31 +00:00
|
|
|
|
2003-05-08 22:21:05 +00:00
|
|
|
U_CFUNC
|
|
|
|
UCollator* ucol_open_internal(const char* loc, UErrorCode* status);
|
|
|
|
|
2001-11-13 22:55:05 +00:00
|
|
|
#if 0
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2001-03-30 00:23:46 +00:00
|
|
|
void ucol_putOptionsToHeader(UCollator* result, UColOptionSet * opts, UErrorCode *status);
|
2001-11-13 22:55:05 +00:00
|
|
|
#endif
|
2001-02-26 10:28:56 +00:00
|
|
|
|
2001-10-20 01:09:31 +00:00
|
|
|
U_CFUNC
|
2002-09-04 06:02:13 +00:00
|
|
|
void ucol_updateInternalState(UCollator *coll, UErrorCode *status);
|
2001-03-22 23:11:22 +00:00
|
|
|
|
2007-06-03 06:08:46 +00:00
|
|
|
U_CFUNC uint32_t U_EXPORT2 ucol_getFirstCE(const UCollator *coll, UChar u, UErrorCode *status);
|
2002-07-16 01:46:42 +00:00
|
|
|
U_CAPI UBool U_EXPORT2 ucol_isTailored(const UCollator *coll, const UChar u, UErrorCode *status);
|
2001-03-22 23:11:22 +00:00
|
|
|
|
2003-04-30 00:49:01 +00:00
|
|
|
U_CAPI const InverseUCATableHeader* U_EXPORT2 ucol_initInverseUCA(UErrorCode *status);
|
2003-09-24 00:17:15 +00:00
|
|
|
|
2002-06-13 18:33:19 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
2008-01-05 01:27:56 +00:00
|
|
|
uprv_uca_initImplicitConstants(UErrorCode *status);
|
2004-01-16 07:09:12 +00:00
|
|
|
|
|
|
|
U_CAPI uint32_t U_EXPORT2
|
|
|
|
uprv_uca_getImplicitFromRaw(UChar32 cp);
|
|
|
|
|
2007-06-03 06:08:46 +00:00
|
|
|
/*U_CFUNC uint32_t U_EXPORT2
|
|
|
|
uprv_uca_getImplicitPrimary(UChar32 cp);*/
|
2004-01-16 07:09:12 +00:00
|
|
|
|
|
|
|
U_CAPI UChar32 U_EXPORT2
|
|
|
|
uprv_uca_getRawFromImplicit(uint32_t implicit);
|
2001-08-06 22:28:20 +00:00
|
|
|
|
2004-01-16 23:44:58 +00:00
|
|
|
U_CAPI UChar32 U_EXPORT2
|
|
|
|
uprv_uca_getRawFromCodePoint(UChar32 i);
|
|
|
|
|
|
|
|
U_CAPI UChar32 U_EXPORT2
|
|
|
|
uprv_uca_getCodePointFromRaw(UChar32 i);
|
|
|
|
|
2010-11-01 22:23:49 +00:00
|
|
|
typedef const UChar* GetCollationRulesFunction(void* context, const char* locale, const char* type, int32_t* pLength, UErrorCode* status);
|
|
|
|
|
|
|
|
U_CAPI UCollator* U_EXPORT2
|
|
|
|
ucol_openRulesForImport( const UChar *rules,
|
|
|
|
int32_t rulesLength,
|
|
|
|
UColAttributeValue normalizationMode,
|
|
|
|
UCollationStrength strength,
|
|
|
|
UParseError *parseError,
|
|
|
|
GetCollationRulesFunction importFunc,
|
|
|
|
void* context,
|
|
|
|
UErrorCode *status);
|
|
|
|
|
2010-11-04 20:12:39 +00:00
|
|
|
|
2011-04-12 18:23:27 +00:00
|
|
|
U_CFUNC void U_EXPORT2
|
2011-03-18 22:52:30 +00:00
|
|
|
ucol_buildPermutationTable(UCollator *coll, UErrorCode *status);
|
|
|
|
|
2011-04-12 18:23:27 +00:00
|
|
|
U_CFUNC int U_EXPORT2
|
2011-03-18 22:52:30 +00:00
|
|
|
ucol_getLeadBytesForReorderCode(const UCollator *uca, int reorderCode, uint16_t* returnLeadBytes, int returnCapacity);
|
2010-11-04 20:12:39 +00:00
|
|
|
|
2011-04-12 18:23:27 +00:00
|
|
|
U_CFUNC int U_EXPORT2
|
2011-03-18 22:52:30 +00:00
|
|
|
ucol_getReorderCodesForLeadByte(const UCollator *uca, int leadByte, int16_t* returnReorderCodes, int returnCapacity);
|
2010-10-27 18:02:52 +00:00
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#ifdef __cplusplus
|
2001-08-06 22:28:20 +00:00
|
|
|
/*
|
|
|
|
* Test whether a character is potentially "unsafe" for use as a collation
|
|
|
|
* starting point. Unsafe chars are those with combining class != 0 plus
|
|
|
|
* those that are the 2nd thru nth character in a contraction sequence.
|
|
|
|
*
|
|
|
|
* Function is in header file because it's used in both collation and string search,
|
|
|
|
* and needs to be inline for performance.
|
|
|
|
*/
|
2001-10-09 20:23:39 +00:00
|
|
|
static inline UBool ucol_unsafeCP(UChar c, const UCollator *coll) {
|
2001-08-06 22:28:20 +00:00
|
|
|
int32_t hash;
|
|
|
|
uint8_t htbyte;
|
|
|
|
|
|
|
|
if (c < coll->minUnsafeCP) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hash = c;
|
|
|
|
if (hash >= UCOL_UNSAFECP_TABLE_SIZE*8) {
|
2011-07-27 05:53:56 +00:00
|
|
|
if(U16_IS_SURROGATE(c)) {
|
2007-12-28 20:08:41 +00:00
|
|
|
/* Lead or trail surrogate */
|
2001-09-18 18:37:57 +00:00
|
|
|
/* These are always considered unsafe. */
|
2001-08-06 22:28:20 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
hash = (hash & UCOL_UNSAFECP_TABLE_MASK) + 256;
|
|
|
|
}
|
|
|
|
htbyte = coll->unsafeCP[hash>>3];
|
2007-12-28 20:08:41 +00:00
|
|
|
return ((htbyte >> (hash & 7)) & 1);
|
2001-08-06 22:28:20 +00:00
|
|
|
}
|
2011-07-23 00:10:30 +00:00
|
|
|
#endif /* __cplusplus */
|
2001-10-09 20:23:39 +00:00
|
|
|
|
2008-06-09 21:18:46 +00:00
|
|
|
/* The offsetBuffer in collIterate might need to be freed to avoid memory leaks. */
|
2010-11-16 21:46:24 +00:00
|
|
|
void ucol_freeOffsetBuffer(U_NAMESPACE_QUALIFIER collIterate *s);
|
2008-06-09 21:18:46 +00:00
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_COLLATION */
|
|
|
|
|
2000-12-13 18:08:27 +00:00
|
|
|
#endif
|