1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *******************************************************************************
38393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius *   Copyright (C) 2003-2013, International Business Machines
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   Corporation and others.  All Rights Reserved.
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *******************************************************************************
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   file name:  ucm.h
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   encoding:   US-ASCII
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   tab size:   8 (not used)
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   indentation:4
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   created on: 2003jun20
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   created by: Markus W. Scherer
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   Definitions for the .ucm file parser and handler module ucm.c.
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef __UCM_H__
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define __UCM_H__
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ucnvmbcs.h"
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ucnv_ext.h"
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "filestrm.h"
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdio.h>
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_CONVERSION
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_BEGIN
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* constants for UCMapping.moveFlag */
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum {
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCM_MOVE_TO_EXT=1,
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCM_REMOVE_MAPPING=2
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Per-mapping data structure
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * u if uLen==1: Unicode code point
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   else index to uLen code points
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * b if bLen<=4: up to 4 bytes
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   else index to bLen bytes
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * uLen number of code points
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * bLen number of words containing left-justified bytes
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * bIsMultipleChars indicates that the bytes contain more than one sequence
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                  according to the state table
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * f flag for roundtrip (0), fallback (1), sub mapping (2), reverse fallback (3)
488393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius *   or "good one-way" mapping (4).
498393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius *   Same values as in the source file after |
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCMapping {
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar32 u;
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    union {
54b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        uint32_t idx;
55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        uint8_t bytes[4];
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } b;
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int8_t uLen, bLen, f, moveFlag;
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} UCMapping;
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* constants for UCMTable.flagsType */
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum {
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCM_FLAGS_INITIAL,  /* no mappings parsed yet */
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCM_FLAGS_EXPLICIT, /* .ucm file has mappings with | fallback indicators */
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCM_FLAGS_IMPLICIT, /* .ucm file has mappings without | fallback indicators, later wins */
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCM_FLAGS_MIXED     /* both implicit and explicit */
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCMTable {
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCMapping *mappings;
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t mappingsCapacity, mappingsLength;
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar32 *codePoints;
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t codePointsCapacity, codePointsLength;
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint8_t *bytes;
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t bytesCapacity, bytesLength;
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* index map for mapping by bytes first */
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t *reverseMap;
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint8_t unicodeMask;
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int8_t flagsType; /* UCM_FLAGS_INITIAL etc. */
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool isSorted;
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} UCMTable;
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum {
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MBCS_STATE_FLAG_DIRECT=1,
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MBCS_STATE_FLAG_SURROGATES,
89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MBCS_STATE_FLAG_READY=16
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCMStates {
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t stateTable[MBCS_MAX_STATE_COUNT][256];
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint32_t stateFlags[MBCS_MAX_STATE_COUNT],
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             stateOffsetSum[MBCS_MAX_STATE_COUNT];
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t countStates, minCharLength, maxCharLength, countToUCodeUnits;
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int8_t conversionType, outputType;
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} UCMStates;
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCMFile {
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCMTable *base, *ext;
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UCMStates states;
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char baseName[UCNV_MAX_CONVERTER_NAME_LENGTH];
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} UCMFile;
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* simple accesses ---------------------------------------------------------- */
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCM_GET_CODE_POINTS(t, m) \
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    (((m)->uLen==1) ? &(m)->u : (t)->codePoints+(m)->u)
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCM_GET_BYTES(t, m) \
115b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    (((m)->bLen<=4) ? (m)->b.bytes : (t)->bytes+(m)->b.idx)
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* APIs --------------------------------------------------------------------- */
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UCMFile * U_EXPORT2
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_open(void);
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_close(UCMFile *ucm);
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_parseHeaderLine(UCMFile *ucm,
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    char *line, char **pKey, char **pValue);
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* @return -1 illegal bytes  0 suitable for base table  1 needs to go into extension table */
130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_mappingType(UCMStates *baseStates,
132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UCMapping *m,
133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UChar32 codePoints[UCNV_EXT_MAX_UCHARS],
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                uint8_t bytes[UCNV_EXT_MAX_BYTES]);
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* add a mapping to the base or extension table as appropriate */
137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_addMappingAuto(UCMFile *ucm, UBool forBase, UCMStates *baseStates,
139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   UCMapping *m,
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   UChar32 codePoints[UCNV_EXT_MAX_UCHARS],
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   uint8_t bytes[UCNV_EXT_MAX_BYTES]);
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_addMappingFromLine(UCMFile *ucm, const char *line, UBool forBase, UCMStates *baseStates);
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UCMTable * U_EXPORT2
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_openTable(void);
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_closeTable(UCMTable *table);
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_resetTable(UCMTable *table);
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_sortTable(UCMTable *t);
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Remove mappings with their move flag set from the base table
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and move some of them (with UCM_MOVE_TO_EXT) to the extension table.
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_moveMappings(UCMTable *base, UCMTable *ext);
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Read a table from a .ucm file, from after the CHARMAP line to
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * including the END CHARMAP line.
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_readTable(UCMFile *ucm, FileStream* convFile,
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              UBool forBase, UCMStates *baseStates,
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              UErrorCode *pErrorCode);
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Check the validity of mappings against a base table's states;
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * necessary for extension-only tables that were read before their base tables.
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_checkValidity(UCMTable *ext, UCMStates *baseStates);
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Check a base table against an extension table.
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the moveTarget!=NULL if it is possible to move mappings from the base.
185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is the case where base and extension tables are parsed from a single file
186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (moveTarget==ext)
187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or when delta file mappings are subtracted from a base table.
188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When a base table cannot be modified because a delta file is parsed in makeconv,
190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then set moveTarget=NULL.
191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if(intersectBase) then mappings that exist in the base table but not in
193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the extension table are moved to moveTarget instead of showing an error.
194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Special mode:
196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If intersectBase==2 for a DBCS extension table, then SBCS mappings are
197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * not moved out of the base unless their Unicode input requires it.
198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This helps ucmkbase generate base tables for DBCS-only extension .cnv files.
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For both tables in the same file, the extension table is automatically
201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * built.
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For separate files, the extension file can use a complete mapping table (.ucm file),
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * so that common mappings need not be stripped out manually.
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Sort both tables, and then for each mapping direction:
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If intersectBase is TRUE and the base table contains a mapping
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that does not exist in the extension table, then this mapping is moved
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to moveTarget.
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - otherwise -
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the base table contains a mapping for which the input sequence is
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the same as the extension input, then
216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - if the output is the same: remove the extension mapping
217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - else: error
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the base table contains a mapping for which the input sequence is
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a prefix of the extension input, then
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - if moveTarget!=NULL: move the base mapping to the moveTarget table
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - else: error
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return FALSE in case of an irreparable error
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_checkBaseExt(UCMStates *baseStates, UCMTable *base, UCMTable *ext,
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                 UCMTable *moveTarget, UBool intersectBase);
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_printTable(UCMTable *table, FILE *f, UBool byUnicode);
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_printMapping(UCMTable *table, UCMapping *m, FILE *f);
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_addState(UCMStates *states, const char *s);
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
24150294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoucm_processStates(UCMStates *states, UBool ignoreSISOCheck);
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_countChars(UCMStates *states,
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru               const uint8_t *bytes, int32_t length);
246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int8_t U_EXPORT2
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_parseBytes(uint8_t bytes[UCNV_EXT_MAX_BYTES], const char *line, const char **ps);
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_parseMappingLine(UCMapping *m,
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     UChar32 codePoints[UCNV_EXT_MAX_UCHARS],
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     uint8_t bytes[UCNV_EXT_MAX_BYTES],
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     const char *line);
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_addMapping(UCMTable *table,
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru               UCMapping *m,
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru               UChar32 codePoints[UCNV_EXT_MAX_UCHARS],
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru               uint8_t bytes[UCNV_EXT_MAX_BYTES]);
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* very makeconv-specific functions ----------------------------------------- */
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* finalize and optimize states after the toUnicode mappings are processed */
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_optimizeStates(UCMStates *states,
268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   uint16_t **pUnicodeCodeUnits,
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   _MBCSToUFallback *toUFallbacks, int32_t countToUFallbacks,
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   UBool verbose);
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* moved here because it is used inside ucmstate.c */
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_findFallback(_MBCSToUFallback *toUFallbacks, int32_t countToUFallbacks,
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                 uint32_t offset);
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* very rptp2ucm-specific functions ----------------------------------------- */
278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Input: Separate tables with mappings from/to Unicode,
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subchar and subchar1 (0 if none).
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * All mappings must have flag 0.
283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Output: fromUTable will contain the union of mappings with the correct
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * precision flags, and be sorted.
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI void U_EXPORT2
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_mergeTables(UCMTable *fromUTable, UCMTable *toUTable,
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                const uint8_t *subchar, int32_t subcharLength,
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                uint8_t subchar1);
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucm_separateMappings(UCMFile *ucm, UBool isSISO);
294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_END
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
301