sl@0
|
1 |
/*
|
sl@0
|
2 |
******************************************************************************
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* Copyright (C) 2003-2004, International Business Machines
|
sl@0
|
5 |
* Corporation and others. All Rights Reserved.
|
sl@0
|
6 |
*
|
sl@0
|
7 |
******************************************************************************
|
sl@0
|
8 |
* file name: ucnv_ext.h
|
sl@0
|
9 |
* encoding: US-ASCII
|
sl@0
|
10 |
* tab size: 8 (not used)
|
sl@0
|
11 |
* indentation:4
|
sl@0
|
12 |
*
|
sl@0
|
13 |
* created on: 2003jun13
|
sl@0
|
14 |
* created by: Markus W. Scherer
|
sl@0
|
15 |
*
|
sl@0
|
16 |
* Conversion extensions
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef __UCNV_EXT_H__
|
sl@0
|
20 |
#define __UCNV_EXT_H__
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "unicode/utypes.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
#if !UCONFIG_NO_CONVERSION
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "unicode/ucnv.h"
|
sl@0
|
27 |
#include "ucnv_cnv.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
/*
|
sl@0
|
30 |
* See icuhtml/design/conversion/conversion_extensions.html
|
sl@0
|
31 |
*
|
sl@0
|
32 |
* Conversion extensions serve two purposes:
|
sl@0
|
33 |
* 1. They support m:n mappings.
|
sl@0
|
34 |
* 2. They support extension-only conversion files that are used together
|
sl@0
|
35 |
* with the regular conversion data in base files.
|
sl@0
|
36 |
*
|
sl@0
|
37 |
* A base file may contain an extension table (explicitly requested or
|
sl@0
|
38 |
* implicitly generated for m:n mappings), but its extension table is not
|
sl@0
|
39 |
* used when an extension-only file is used.
|
sl@0
|
40 |
*
|
sl@0
|
41 |
* It is an error if a base file contains any regular (not extension) mapping
|
sl@0
|
42 |
* from the same sequence as a mapping in the extension file
|
sl@0
|
43 |
* because the base mapping would hide the extension mapping.
|
sl@0
|
44 |
*
|
sl@0
|
45 |
*
|
sl@0
|
46 |
* Data for conversion extensions:
|
sl@0
|
47 |
*
|
sl@0
|
48 |
* One set of data structures per conversion direction (to/from Unicode).
|
sl@0
|
49 |
* The data structures are sorted by input units to allow for binary search.
|
sl@0
|
50 |
* Input sequences of more than one unit are handled like contraction tables
|
sl@0
|
51 |
* in collation:
|
sl@0
|
52 |
* The lookup value of a unit points to another table that is to be searched
|
sl@0
|
53 |
* for the next unit, recursively.
|
sl@0
|
54 |
*
|
sl@0
|
55 |
* For conversion from Unicode, the initial code point is looked up in
|
sl@0
|
56 |
* a 3-stage trie for speed,
|
sl@0
|
57 |
* with an additional table of unique results to save space.
|
sl@0
|
58 |
*
|
sl@0
|
59 |
* Long output strings are stored in separate arrays, with length and index
|
sl@0
|
60 |
* in the lookup tables.
|
sl@0
|
61 |
* Output results also include a flag distinguishing roundtrip from
|
sl@0
|
62 |
* (reverse) fallback mappings.
|
sl@0
|
63 |
*
|
sl@0
|
64 |
* Input Unicode strings must not begin or end with unpaired surrogates
|
sl@0
|
65 |
* to avoid problems with matches on parts of surrogate pairs.
|
sl@0
|
66 |
*
|
sl@0
|
67 |
* Mappings from multiple characters (code points or codepage state
|
sl@0
|
68 |
* table sequences) must be searched preferring the longest match.
|
sl@0
|
69 |
* For this to work and be efficient, the variable-width table must contain
|
sl@0
|
70 |
* all mappings that contain prefixes of the multiple characters.
|
sl@0
|
71 |
* If an extension table is built on top of a base table in another file
|
sl@0
|
72 |
* and a base table entry is a prefix of a multi-character mapping, then
|
sl@0
|
73 |
* this is an error.
|
sl@0
|
74 |
*
|
sl@0
|
75 |
*
|
sl@0
|
76 |
* Implementation note:
|
sl@0
|
77 |
*
|
sl@0
|
78 |
* Currently, the parser and several checks in the code limit the number
|
sl@0
|
79 |
* of UChars or bytes in a mapping to
|
sl@0
|
80 |
* UCNV_EXT_MAX_UCHARS and UCNV_EXT_MAX_BYTES, respectively,
|
sl@0
|
81 |
* which are output value limits in the data structure.
|
sl@0
|
82 |
*
|
sl@0
|
83 |
* For input, this is not strictly necessary - it is a hard limit only for the
|
sl@0
|
84 |
* buffers in UConverter that are used to store partial matches.
|
sl@0
|
85 |
*
|
sl@0
|
86 |
* Input sequences could otherwise be arbitrarily long if partial matches
|
sl@0
|
87 |
* need not be stored (i.e., if a sequence does not span several buffers with too
|
sl@0
|
88 |
* many units before the last buffer), although then results would differ
|
sl@0
|
89 |
* depending on whether partial matches exceed the limits or not,
|
sl@0
|
90 |
* which depends on the pattern of buffer sizes.
|
sl@0
|
91 |
*
|
sl@0
|
92 |
*
|
sl@0
|
93 |
* Data structure:
|
sl@0
|
94 |
*
|
sl@0
|
95 |
* int32_t indexes[>=32];
|
sl@0
|
96 |
*
|
sl@0
|
97 |
* Array of indexes and lengths etc. The length of the array is at least 32.
|
sl@0
|
98 |
* The actual length is stored in indexes[0] to be forward compatible.
|
sl@0
|
99 |
*
|
sl@0
|
100 |
* Each index to another array is the number of bytes from indexes[].
|
sl@0
|
101 |
* Each length of an array is the number of array base units in that array.
|
sl@0
|
102 |
*
|
sl@0
|
103 |
* Some of the structures may not be present, in which case their indexes
|
sl@0
|
104 |
* and lengths are 0.
|
sl@0
|
105 |
*
|
sl@0
|
106 |
* Usage of indexes[i]:
|
sl@0
|
107 |
* [0] length of indexes[]
|
sl@0
|
108 |
*
|
sl@0
|
109 |
* // to Unicode table
|
sl@0
|
110 |
* [1] index of toUTable[] (array of uint32_t)
|
sl@0
|
111 |
* [2] length of toUTable[]
|
sl@0
|
112 |
* [3] index of toUUChars[] (array of UChar)
|
sl@0
|
113 |
* [4] length of toUUChars[]
|
sl@0
|
114 |
*
|
sl@0
|
115 |
* // from Unicode table, not for the initial code point
|
sl@0
|
116 |
* [5] index of fromUTableUChars[] (array of UChar)
|
sl@0
|
117 |
* [6] index of fromUTableValues[] (array of uint32_t)
|
sl@0
|
118 |
* [7] length of fromUTableUChars[] and fromUTableValues[]
|
sl@0
|
119 |
* [8] index of fromUBytes[] (array of char)
|
sl@0
|
120 |
* [9] length of fromUBytes[]
|
sl@0
|
121 |
*
|
sl@0
|
122 |
* // from Unicode trie for initial-code point lookup
|
sl@0
|
123 |
* [10] index of fromUStage12[] (combined array of uint16_t for stages 1 & 2)
|
sl@0
|
124 |
* [11] length of stage 1 portion of fromUStage12[]
|
sl@0
|
125 |
* [12] length of fromUStage12[]
|
sl@0
|
126 |
* [13] index of fromUStage3[] (array of uint16_t indexes into fromUStage3b[])
|
sl@0
|
127 |
* [14] length of fromUStage3[]
|
sl@0
|
128 |
* [15] index of fromUStage3b[] (array of uint32_t like fromUTableValues[])
|
sl@0
|
129 |
* [16] length of fromUStage3b[]
|
sl@0
|
130 |
*
|
sl@0
|
131 |
* [17] Bit field containing numbers of bytes:
|
sl@0
|
132 |
* 31..24 reserved, 0
|
sl@0
|
133 |
* 23..16 maximum input bytes
|
sl@0
|
134 |
* 15.. 8 maximum output bytes
|
sl@0
|
135 |
* 7.. 0 maximum bytes per UChar
|
sl@0
|
136 |
*
|
sl@0
|
137 |
* [18] Bit field containing numbers of UChars:
|
sl@0
|
138 |
* 31..24 reserved, 0
|
sl@0
|
139 |
* 23..16 maximum input UChars
|
sl@0
|
140 |
* 15.. 8 maximum output UChars
|
sl@0
|
141 |
* 7.. 0 maximum UChars per byte
|
sl@0
|
142 |
*
|
sl@0
|
143 |
* [19] Bit field containing flags:
|
sl@0
|
144 |
* (extension table unicodeMask)
|
sl@0
|
145 |
* 1 UCNV_HAS_SURROGATES flag for the extension table
|
sl@0
|
146 |
* 0 UCNV_HAS_SUPPLEMENTARY flag for the extension table
|
sl@0
|
147 |
*
|
sl@0
|
148 |
* [20]..[30] reserved, 0
|
sl@0
|
149 |
* [31] number of bytes for the entire extension structure
|
sl@0
|
150 |
* [>31] reserved; there are indexes[0] indexes
|
sl@0
|
151 |
*
|
sl@0
|
152 |
*
|
sl@0
|
153 |
* uint32_t toUTable[];
|
sl@0
|
154 |
*
|
sl@0
|
155 |
* Array of byte/value pairs for lookups for toUnicode conversion.
|
sl@0
|
156 |
* The array is partitioned into sections like collation contraction tables.
|
sl@0
|
157 |
* Each section contains one word with the number of following words and
|
sl@0
|
158 |
* a default value for when the lookup in this section yields no match.
|
sl@0
|
159 |
*
|
sl@0
|
160 |
* A section is sorted in ascending order of input bytes,
|
sl@0
|
161 |
* allowing for fast linear or binary searches.
|
sl@0
|
162 |
* The builder may store entries for a contiguous range of byte values
|
sl@0
|
163 |
* (compare difference between the first and last one with count),
|
sl@0
|
164 |
* which then allows for direct array access.
|
sl@0
|
165 |
* The builder should always do this for the initial table section.
|
sl@0
|
166 |
*
|
sl@0
|
167 |
* Entries may have 0 values, see below.
|
sl@0
|
168 |
* No two entries in a section have the same byte values.
|
sl@0
|
169 |
*
|
sl@0
|
170 |
* Each uint32_t contains an input byte value in bits 31..24 and the
|
sl@0
|
171 |
* corresponding lookup value in bits 23..0.
|
sl@0
|
172 |
* Interpret the value as follows:
|
sl@0
|
173 |
* if(value==0) {
|
sl@0
|
174 |
* no match, see below
|
sl@0
|
175 |
* } else if(value<0x1f0000) {
|
sl@0
|
176 |
* partial match - use value as index to the next toUTable section
|
sl@0
|
177 |
* and match the next unit; (value indexes toUTable[value])
|
sl@0
|
178 |
* } else {
|
sl@0
|
179 |
* if(bit 23 set) {
|
sl@0
|
180 |
* roundtrip;
|
sl@0
|
181 |
* } else {
|
sl@0
|
182 |
* fallback;
|
sl@0
|
183 |
* }
|
sl@0
|
184 |
* unset value bit 23;
|
sl@0
|
185 |
* if(value<=0x2fffff) {
|
sl@0
|
186 |
* (value-0x1f0000) is a code point; (BMP: value<=0x1fffff)
|
sl@0
|
187 |
* } else {
|
sl@0
|
188 |
* bits 17..0 (value&0x3ffff) is an index to
|
sl@0
|
189 |
* the result UChars in toUUChars[]; (0 indexes toUUChars[0])
|
sl@0
|
190 |
* length of the result=((value>>18)-12); (length=0..19)
|
sl@0
|
191 |
* }
|
sl@0
|
192 |
* }
|
sl@0
|
193 |
*
|
sl@0
|
194 |
* The first word in a section contains the number of following words in the
|
sl@0
|
195 |
* input byte position (bits 31..24, number=1..0xff).
|
sl@0
|
196 |
* The value of the initial word is used when the current byte is not found
|
sl@0
|
197 |
* in this section.
|
sl@0
|
198 |
* If the value is not 0, then it represents a result as above.
|
sl@0
|
199 |
* If the value is 0, then the search has to return a shorter match with an
|
sl@0
|
200 |
* earlier default value as the result, or result in "unmappable" even for the
|
sl@0
|
201 |
* initial bytes.
|
sl@0
|
202 |
* If the value is 0 for the initial toUTable entry, then the initial byte
|
sl@0
|
203 |
* does not start any mapping input.
|
sl@0
|
204 |
*
|
sl@0
|
205 |
*
|
sl@0
|
206 |
* UChar toUUChars[];
|
sl@0
|
207 |
*
|
sl@0
|
208 |
* Contains toUnicode mapping results, stored as sequences of UChars.
|
sl@0
|
209 |
* Indexes and lengths stored in the toUTable[].
|
sl@0
|
210 |
*
|
sl@0
|
211 |
*
|
sl@0
|
212 |
* UChar fromUTableUChars[];
|
sl@0
|
213 |
* uint32_t fromUTableValues[];
|
sl@0
|
214 |
*
|
sl@0
|
215 |
* The fromUTable is split into two arrays, but works otherwise much like
|
sl@0
|
216 |
* the toUTable. The array is partitioned into sections like collation
|
sl@0
|
217 |
* contraction tables and toUTable.
|
sl@0
|
218 |
* A row in the table consists of same-index entries in fromUTableUChars[]
|
sl@0
|
219 |
* and fromUTableValues[].
|
sl@0
|
220 |
*
|
sl@0
|
221 |
* Interpret a value as follows:
|
sl@0
|
222 |
* if(value==0) {
|
sl@0
|
223 |
* no match, see below
|
sl@0
|
224 |
* } else if(value<=0xffffff) { (bits 31..24 are 0)
|
sl@0
|
225 |
* partial match - use value as index to the next fromUTable section
|
sl@0
|
226 |
* and match the next unit; (value indexes fromUTable[value])
|
sl@0
|
227 |
* } else {
|
sl@0
|
228 |
* if(value==0x80000001) {
|
sl@0
|
229 |
* return no mapping, but request for <subchar1>;
|
sl@0
|
230 |
* }
|
sl@0
|
231 |
* if(bit 31 set) {
|
sl@0
|
232 |
* roundtrip;
|
sl@0
|
233 |
* } else {
|
sl@0
|
234 |
* fallback;
|
sl@0
|
235 |
* }
|
sl@0
|
236 |
* // bits 30..29 reserved, 0
|
sl@0
|
237 |
* length=(value>>24)&0x1f; (bits 28..24)
|
sl@0
|
238 |
* if(length==1..3) {
|
sl@0
|
239 |
* bits 23..0 contain 1..3 bytes, padded with 00s on the left;
|
sl@0
|
240 |
* } else {
|
sl@0
|
241 |
* bits 23..0 (value&0xffffff) is an index to
|
sl@0
|
242 |
* the result bytes in fromUBytes[]; (0 indexes fromUBytes[0])
|
sl@0
|
243 |
* }
|
sl@0
|
244 |
* }
|
sl@0
|
245 |
*
|
sl@0
|
246 |
* The first pair in a section contains the number of following pairs in the
|
sl@0
|
247 |
* UChar position (16 bits, number=1..0xffff).
|
sl@0
|
248 |
* The value of the initial pair is used when the current UChar is not found
|
sl@0
|
249 |
* in this section.
|
sl@0
|
250 |
* If the value is not 0, then it represents a result as above.
|
sl@0
|
251 |
* If the value is 0, then the search has to return a shorter match with an
|
sl@0
|
252 |
* earlier default value as the result, or result in "unmappable" even for the
|
sl@0
|
253 |
* initial UChars.
|
sl@0
|
254 |
*
|
sl@0
|
255 |
* If the from Unicode trie is present, then the from Unicode search tables
|
sl@0
|
256 |
* are not used for initial code points.
|
sl@0
|
257 |
* In this case, the first entries (index 0) in the tables are not used
|
sl@0
|
258 |
* (reserved, set to 0) because a value of 0 is used in trie results
|
sl@0
|
259 |
* to indicate no mapping.
|
sl@0
|
260 |
*
|
sl@0
|
261 |
*
|
sl@0
|
262 |
* uint16_t fromUStage12[];
|
sl@0
|
263 |
*
|
sl@0
|
264 |
* Stages 1 & 2 of a trie that maps an initial code point.
|
sl@0
|
265 |
* Indexes in stage 1 are all offset by the length of stage 1 so that the
|
sl@0
|
266 |
* same array pointer can be used for both stages.
|
sl@0
|
267 |
* If (c>>10)>=(length of stage 1) then c does not start any mapping.
|
sl@0
|
268 |
* Same bit distribution as for regular conversion tries.
|
sl@0
|
269 |
*
|
sl@0
|
270 |
*
|
sl@0
|
271 |
* uint16_t fromUStage3[];
|
sl@0
|
272 |
* uint32_t fromUStage3b[];
|
sl@0
|
273 |
*
|
sl@0
|
274 |
* Stage 3 of the trie. The first array simply contains indexes to the second,
|
sl@0
|
275 |
* which contains words in the same format as fromUTableValues[].
|
sl@0
|
276 |
* Use a stage 3 granularity of 4, which allows for 256k stage 3 entries,
|
sl@0
|
277 |
* and 16-bit entries in stage 3 allow for 64k stage 3b entries.
|
sl@0
|
278 |
* The stage 3 granularity means that the stage 2 entry needs to be left-shifted.
|
sl@0
|
279 |
*
|
sl@0
|
280 |
* Two arrays are used because it is expected that more than half of the stage 3
|
sl@0
|
281 |
* entries will be zero. The 16-bit index stage 3 array saves space even
|
sl@0
|
282 |
* considering storing a total of 6 bytes per non-zero entry in both arrays
|
sl@0
|
283 |
* together.
|
sl@0
|
284 |
* Using a stage 3 granularity of >1 diminishes the compactability in that stage
|
sl@0
|
285 |
* but provides a larger effective addressing space in stage 2.
|
sl@0
|
286 |
* All but the final result stage use 16-bit entries to save space.
|
sl@0
|
287 |
*
|
sl@0
|
288 |
* fromUStage3b[] contains a zero for "no mapping" at its index 0,
|
sl@0
|
289 |
* and may contain UCNV_EXT_FROM_U_SUBCHAR1 at index 1 for "<subchar1> SUB mapping"
|
sl@0
|
290 |
* (i.e., "no mapping" with preference for <subchar1> rather than <subchar>),
|
sl@0
|
291 |
* and all other items are unique non-zero results.
|
sl@0
|
292 |
*
|
sl@0
|
293 |
* The default value of a fromUTableValues[] section that is referenced
|
sl@0
|
294 |
* _directly_ from a fromUStage3b[] item may also be UCNV_EXT_FROM_U_SUBCHAR1,
|
sl@0
|
295 |
* but this value must not occur anywhere else in fromUTableValues[]
|
sl@0
|
296 |
* because "no mapping" is always a property of a single code point,
|
sl@0
|
297 |
* never of multiple.
|
sl@0
|
298 |
*
|
sl@0
|
299 |
*
|
sl@0
|
300 |
* char fromUBytes[];
|
sl@0
|
301 |
*
|
sl@0
|
302 |
* Contains fromUnicode mapping results, stored as sequences of chars.
|
sl@0
|
303 |
* Indexes and lengths stored in the fromUTableValues[].
|
sl@0
|
304 |
*/
|
sl@0
|
305 |
enum {
|
sl@0
|
306 |
UCNV_EXT_INDEXES_LENGTH, /* 0 */
|
sl@0
|
307 |
|
sl@0
|
308 |
UCNV_EXT_TO_U_INDEX, /* 1 */
|
sl@0
|
309 |
UCNV_EXT_TO_U_LENGTH,
|
sl@0
|
310 |
UCNV_EXT_TO_U_UCHARS_INDEX,
|
sl@0
|
311 |
UCNV_EXT_TO_U_UCHARS_LENGTH,
|
sl@0
|
312 |
|
sl@0
|
313 |
UCNV_EXT_FROM_U_UCHARS_INDEX, /* 5 */
|
sl@0
|
314 |
UCNV_EXT_FROM_U_VALUES_INDEX,
|
sl@0
|
315 |
UCNV_EXT_FROM_U_LENGTH,
|
sl@0
|
316 |
UCNV_EXT_FROM_U_BYTES_INDEX,
|
sl@0
|
317 |
UCNV_EXT_FROM_U_BYTES_LENGTH,
|
sl@0
|
318 |
|
sl@0
|
319 |
UCNV_EXT_FROM_U_STAGE_12_INDEX, /* 10 */
|
sl@0
|
320 |
UCNV_EXT_FROM_U_STAGE_1_LENGTH,
|
sl@0
|
321 |
UCNV_EXT_FROM_U_STAGE_12_LENGTH,
|
sl@0
|
322 |
UCNV_EXT_FROM_U_STAGE_3_INDEX,
|
sl@0
|
323 |
UCNV_EXT_FROM_U_STAGE_3_LENGTH,
|
sl@0
|
324 |
UCNV_EXT_FROM_U_STAGE_3B_INDEX,
|
sl@0
|
325 |
UCNV_EXT_FROM_U_STAGE_3B_LENGTH,
|
sl@0
|
326 |
|
sl@0
|
327 |
UCNV_EXT_COUNT_BYTES, /* 17 */
|
sl@0
|
328 |
UCNV_EXT_COUNT_UCHARS,
|
sl@0
|
329 |
UCNV_EXT_FLAGS,
|
sl@0
|
330 |
|
sl@0
|
331 |
UCNV_EXT_RESERVED_INDEX, /* 20, moves with additional indexes */
|
sl@0
|
332 |
|
sl@0
|
333 |
UCNV_EXT_SIZE=31,
|
sl@0
|
334 |
UCNV_EXT_INDEXES_MIN_LENGTH=32
|
sl@0
|
335 |
};
|
sl@0
|
336 |
|
sl@0
|
337 |
/* get the pointer to an extension array from indexes[index] */
|
sl@0
|
338 |
#define UCNV_EXT_ARRAY(indexes, index, itemType) \
|
sl@0
|
339 |
((const itemType *)((const char *)(indexes)+(indexes)[index]))
|
sl@0
|
340 |
|
sl@0
|
341 |
#define UCNV_GET_MAX_BYTES_PER_UCHAR(indexes) \
|
sl@0
|
342 |
((indexes)[UCNV_EXT_COUNT_BYTES]&0xff)
|
sl@0
|
343 |
|
sl@0
|
344 |
/* internal API ------------------------------------------------------------- */
|
sl@0
|
345 |
|
sl@0
|
346 |
U_CFUNC UBool
|
sl@0
|
347 |
ucnv_extInitialMatchToU(UConverter *cnv, const int32_t *cx,
|
sl@0
|
348 |
int32_t firstLength,
|
sl@0
|
349 |
const char **src, const char *srcLimit,
|
sl@0
|
350 |
UChar **target, const UChar *targetLimit,
|
sl@0
|
351 |
int32_t **offsets, int32_t srcIndex,
|
sl@0
|
352 |
UBool flush,
|
sl@0
|
353 |
UErrorCode *pErrorCode);
|
sl@0
|
354 |
|
sl@0
|
355 |
U_CFUNC UChar32
|
sl@0
|
356 |
ucnv_extSimpleMatchToU(const int32_t *cx,
|
sl@0
|
357 |
const char *source, int32_t length,
|
sl@0
|
358 |
UBool useFallback);
|
sl@0
|
359 |
|
sl@0
|
360 |
U_CFUNC void
|
sl@0
|
361 |
ucnv_extContinueMatchToU(UConverter *cnv,
|
sl@0
|
362 |
UConverterToUnicodeArgs *pArgs, int32_t srcIndex,
|
sl@0
|
363 |
UErrorCode *pErrorCode);
|
sl@0
|
364 |
|
sl@0
|
365 |
|
sl@0
|
366 |
U_CFUNC UBool
|
sl@0
|
367 |
ucnv_extInitialMatchFromU(UConverter *cnv, const int32_t *cx,
|
sl@0
|
368 |
UChar32 cp,
|
sl@0
|
369 |
const UChar **src, const UChar *srcLimit,
|
sl@0
|
370 |
char **target, const char *targetLimit,
|
sl@0
|
371 |
int32_t **offsets, int32_t srcIndex,
|
sl@0
|
372 |
UBool flush,
|
sl@0
|
373 |
UErrorCode *pErrorCode);
|
sl@0
|
374 |
|
sl@0
|
375 |
U_CFUNC int32_t
|
sl@0
|
376 |
ucnv_extSimpleMatchFromU(const int32_t *cx,
|
sl@0
|
377 |
UChar32 cp, uint32_t *pValue,
|
sl@0
|
378 |
UBool useFallback);
|
sl@0
|
379 |
|
sl@0
|
380 |
U_CFUNC void
|
sl@0
|
381 |
ucnv_extContinueMatchFromU(UConverter *cnv,
|
sl@0
|
382 |
UConverterFromUnicodeArgs *pArgs, int32_t srcIndex,
|
sl@0
|
383 |
UErrorCode *pErrorCode);
|
sl@0
|
384 |
|
sl@0
|
385 |
U_CFUNC void
|
sl@0
|
386 |
ucnv_extGetUnicodeSet(const UConverterSharedData *sharedData,
|
sl@0
|
387 |
const USetAdder *sa,
|
sl@0
|
388 |
UConverterUnicodeSet which,
|
sl@0
|
389 |
UErrorCode *pErrorCode);
|
sl@0
|
390 |
|
sl@0
|
391 |
/* toUnicode helpers -------------------------------------------------------- */
|
sl@0
|
392 |
|
sl@0
|
393 |
#define UCNV_EXT_TO_U_BYTE_SHIFT 24
|
sl@0
|
394 |
#define UCNV_EXT_TO_U_VALUE_MASK 0xffffff
|
sl@0
|
395 |
#define UCNV_EXT_TO_U_MIN_CODE_POINT 0x1f0000
|
sl@0
|
396 |
#define UCNV_EXT_TO_U_MAX_CODE_POINT 0x2fffff
|
sl@0
|
397 |
#define UCNV_EXT_TO_U_ROUNDTRIP_FLAG ((uint32_t)1<<23)
|
sl@0
|
398 |
#define UCNV_EXT_TO_U_INDEX_MASK 0x3ffff
|
sl@0
|
399 |
#define UCNV_EXT_TO_U_LENGTH_SHIFT 18
|
sl@0
|
400 |
#define UCNV_EXT_TO_U_LENGTH_OFFSET 12
|
sl@0
|
401 |
|
sl@0
|
402 |
/* maximum number of indexed UChars */
|
sl@0
|
403 |
#define UCNV_EXT_MAX_UCHARS 19
|
sl@0
|
404 |
|
sl@0
|
405 |
#define UCNV_EXT_TO_U_MAKE_WORD(byte, value) (((uint32_t)(byte)<<UCNV_EXT_TO_U_BYTE_SHIFT)|(value))
|
sl@0
|
406 |
|
sl@0
|
407 |
#define UCNV_EXT_TO_U_GET_BYTE(word) ((word)>>UCNV_EXT_TO_U_BYTE_SHIFT)
|
sl@0
|
408 |
#define UCNV_EXT_TO_U_GET_VALUE(word) ((word)&UCNV_EXT_TO_U_VALUE_MASK)
|
sl@0
|
409 |
|
sl@0
|
410 |
#define UCNV_EXT_TO_U_IS_PARTIAL(value) ((value)<UCNV_EXT_TO_U_MIN_CODE_POINT)
|
sl@0
|
411 |
#define UCNV_EXT_TO_U_GET_PARTIAL_INDEX(value) (value)
|
sl@0
|
412 |
|
sl@0
|
413 |
#define UCNV_EXT_TO_U_IS_ROUNDTRIP(value) (((value)&UCNV_EXT_TO_U_ROUNDTRIP_FLAG)!=0)
|
sl@0
|
414 |
#define UCNV_EXT_TO_U_MASK_ROUNDTRIP(value) ((value)&~UCNV_EXT_TO_U_ROUNDTRIP_FLAG)
|
sl@0
|
415 |
|
sl@0
|
416 |
/* use after masking off the roundtrip flag */
|
sl@0
|
417 |
#define UCNV_EXT_TO_U_IS_CODE_POINT(value) ((value)<=UCNV_EXT_TO_U_MAX_CODE_POINT)
|
sl@0
|
418 |
#define UCNV_EXT_TO_U_GET_CODE_POINT(value) ((value)-UCNV_EXT_TO_U_MIN_CODE_POINT)
|
sl@0
|
419 |
|
sl@0
|
420 |
#define UCNV_EXT_TO_U_GET_INDEX(value) ((value)&UCNV_EXT_TO_U_INDEX_MASK)
|
sl@0
|
421 |
#define UCNV_EXT_TO_U_GET_LENGTH(value) (((value)>>UCNV_EXT_TO_U_LENGTH_SHIFT)-UCNV_EXT_TO_U_LENGTH_OFFSET)
|
sl@0
|
422 |
|
sl@0
|
423 |
/* fromUnicode helpers ------------------------------------------------------ */
|
sl@0
|
424 |
|
sl@0
|
425 |
/* most trie constants are shared with ucnvmbcs.h */
|
sl@0
|
426 |
|
sl@0
|
427 |
/* see similar utrie.h UTRIE_INDEX_SHIFT and UTRIE_DATA_GRANULARITY */
|
sl@0
|
428 |
#define UCNV_EXT_STAGE_2_LEFT_SHIFT 2
|
sl@0
|
429 |
#define UCNV_EXT_STAGE_3_GRANULARITY 4
|
sl@0
|
430 |
|
sl@0
|
431 |
/* trie access, returns the stage 3 value=index to stage 3b; s1Index=c>>10 */
|
sl@0
|
432 |
#define UCNV_EXT_FROM_U(stage12, stage3, s1Index, c) \
|
sl@0
|
433 |
(stage3)[ ((int32_t)(stage12)[ (stage12)[s1Index] +(((c)>>4)&0x3f) ]<<UCNV_EXT_STAGE_2_LEFT_SHIFT) +((c)&0xf) ]
|
sl@0
|
434 |
|
sl@0
|
435 |
#define UCNV_EXT_FROM_U_LENGTH_SHIFT 24
|
sl@0
|
436 |
#define UCNV_EXT_FROM_U_ROUNDTRIP_FLAG ((uint32_t)1<<31)
|
sl@0
|
437 |
#define UCNV_EXT_FROM_U_RESERVED_MASK 0x60000000
|
sl@0
|
438 |
#define UCNV_EXT_FROM_U_DATA_MASK 0xffffff
|
sl@0
|
439 |
|
sl@0
|
440 |
/* special value for "no mapping" to <subchar1> (impossible roundtrip to 0 bytes, value 01) */
|
sl@0
|
441 |
#define UCNV_EXT_FROM_U_SUBCHAR1 0x80000001
|
sl@0
|
442 |
|
sl@0
|
443 |
/* at most 3 bytes in the lower part of the value */
|
sl@0
|
444 |
#define UCNV_EXT_FROM_U_MAX_DIRECT_LENGTH 3
|
sl@0
|
445 |
|
sl@0
|
446 |
/* maximum number of indexed bytes */
|
sl@0
|
447 |
#define UCNV_EXT_MAX_BYTES 0x1f
|
sl@0
|
448 |
|
sl@0
|
449 |
#define UCNV_EXT_FROM_U_IS_PARTIAL(value) (((value)>>UCNV_EXT_FROM_U_LENGTH_SHIFT)==0)
|
sl@0
|
450 |
#define UCNV_EXT_FROM_U_GET_PARTIAL_INDEX(value) (value)
|
sl@0
|
451 |
|
sl@0
|
452 |
#define UCNV_EXT_FROM_U_IS_ROUNDTRIP(value) (((value)&UCNV_EXT_FROM_U_ROUNDTRIP_FLAG)!=0)
|
sl@0
|
453 |
#define UCNV_EXT_FROM_U_MASK_ROUNDTRIP(value) ((value)&~UCNV_EXT_FROM_U_ROUNDTRIP_FLAG)
|
sl@0
|
454 |
|
sl@0
|
455 |
/* use after masking off the roundtrip flag */
|
sl@0
|
456 |
#define UCNV_EXT_FROM_U_GET_LENGTH(value) (int32_t)(((value)>>UCNV_EXT_FROM_U_LENGTH_SHIFT)&UCNV_EXT_MAX_BYTES)
|
sl@0
|
457 |
|
sl@0
|
458 |
/* get bytes or bytes index */
|
sl@0
|
459 |
#define UCNV_EXT_FROM_U_GET_DATA(value) ((value)&UCNV_EXT_FROM_U_DATA_MASK)
|
sl@0
|
460 |
|
sl@0
|
461 |
#endif
|
sl@0
|
462 |
|
sl@0
|
463 |
#endif
|