1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 1999-2011, International Business Machines 6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker * ucnv_cnv.h: 10*0e209d39SAndroid Build Coastguard Worker * Definitions for converter implementations. 11*0e209d39SAndroid Build Coastguard Worker * 12*0e209d39SAndroid Build Coastguard Worker * Modification History: 13*0e209d39SAndroid Build Coastguard Worker * 14*0e209d39SAndroid Build Coastguard Worker * Date Name Description 15*0e209d39SAndroid Build Coastguard Worker * 05/09/00 helena Added implementation to handle fallback mappings. 16*0e209d39SAndroid Build Coastguard Worker * 06/29/2000 helena Major rewrite of the callback APIs. 17*0e209d39SAndroid Build Coastguard Worker */ 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker #ifndef UCNV_CNV_H 20*0e209d39SAndroid Build Coastguard Worker #define UCNV_CNV_H 21*0e209d39SAndroid Build Coastguard Worker 22*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_CONVERSION 25*0e209d39SAndroid Build Coastguard Worker 26*0e209d39SAndroid Build Coastguard Worker #include "unicode/ucnv.h" 27*0e209d39SAndroid Build Coastguard Worker #include "unicode/ucnv_err.h" 28*0e209d39SAndroid Build Coastguard Worker #include "unicode/uset.h" 29*0e209d39SAndroid Build Coastguard Worker #include "uset_imp.h" 30*0e209d39SAndroid Build Coastguard Worker 31*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN 32*0e209d39SAndroid Build Coastguard Worker 33*0e209d39SAndroid Build Coastguard Worker /* this is used in fromUnicode DBCS tables as an "unassigned" marker */ 34*0e209d39SAndroid Build Coastguard Worker #define missingCharMarker 0xFFFF 35*0e209d39SAndroid Build Coastguard Worker 36*0e209d39SAndroid Build Coastguard Worker /* 37*0e209d39SAndroid Build Coastguard Worker * #define missingUCharMarker 0xfffe 38*0e209d39SAndroid Build Coastguard Worker * 39*0e209d39SAndroid Build Coastguard Worker * commented out because there are actually two values used in toUnicode tables: 40*0e209d39SAndroid Build Coastguard Worker * U+fffe "unassigned" 41*0e209d39SAndroid Build Coastguard Worker * U+ffff "illegal" 42*0e209d39SAndroid Build Coastguard Worker */ 43*0e209d39SAndroid Build Coastguard Worker 44*0e209d39SAndroid Build Coastguard Worker /** Forward declaration, see ucnv_bld.h */ 45*0e209d39SAndroid Build Coastguard Worker struct UConverterSharedData; 46*0e209d39SAndroid Build Coastguard Worker typedef struct UConverterSharedData UConverterSharedData; 47*0e209d39SAndroid Build Coastguard Worker 48*0e209d39SAndroid Build Coastguard Worker /* function types for UConverterImpl ---------------------------------------- */ 49*0e209d39SAndroid Build Coastguard Worker 50*0e209d39SAndroid Build Coastguard Worker /* struct with arguments for UConverterLoad and ucnv_load() */ 51*0e209d39SAndroid Build Coastguard Worker typedef struct { 52*0e209d39SAndroid Build Coastguard Worker int32_t size; /* sizeof(UConverterLoadArgs) */ 53*0e209d39SAndroid Build Coastguard Worker int32_t nestedLoads; /* count nested ucnv_load() calls */ 54*0e209d39SAndroid Build Coastguard Worker UBool onlyTestIsLoadable; /* input: don't actually load */ 55*0e209d39SAndroid Build Coastguard Worker UBool reserved0; /* reserved - for good alignment of the pointers */ 56*0e209d39SAndroid Build Coastguard Worker int16_t reserved; /* reserved - for good alignment of the pointers */ 57*0e209d39SAndroid Build Coastguard Worker uint32_t options; 58*0e209d39SAndroid Build Coastguard Worker const char *pkg, *name, *locale; 59*0e209d39SAndroid Build Coastguard Worker } UConverterLoadArgs; 60*0e209d39SAndroid Build Coastguard Worker 61*0e209d39SAndroid Build Coastguard Worker #define UCNV_LOAD_ARGS_INITIALIZER \ 62*0e209d39SAndroid Build Coastguard Worker { (int32_t)sizeof(UConverterLoadArgs), 0, false, false, 0, 0, NULL, NULL, NULL } 63*0e209d39SAndroid Build Coastguard Worker 64*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterLoad) (UConverterSharedData *sharedData, 65*0e209d39SAndroid Build Coastguard Worker UConverterLoadArgs *pArgs, 66*0e209d39SAndroid Build Coastguard Worker const uint8_t *raw, UErrorCode *pErrorCode); 67*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterUnload) (UConverterSharedData *sharedData); 68*0e209d39SAndroid Build Coastguard Worker 69*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterOpen) (UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *pErrorCode); 70*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterClose) (UConverter *cnv); 71*0e209d39SAndroid Build Coastguard Worker 72*0e209d39SAndroid Build Coastguard Worker typedef enum UConverterResetChoice { 73*0e209d39SAndroid Build Coastguard Worker UCNV_RESET_BOTH, 74*0e209d39SAndroid Build Coastguard Worker UCNV_RESET_TO_UNICODE, 75*0e209d39SAndroid Build Coastguard Worker UCNV_RESET_FROM_UNICODE 76*0e209d39SAndroid Build Coastguard Worker } UConverterResetChoice; 77*0e209d39SAndroid Build Coastguard Worker 78*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterReset) (UConverter *cnv, UConverterResetChoice choice); 79*0e209d39SAndroid Build Coastguard Worker 80*0e209d39SAndroid Build Coastguard Worker /* 81*0e209d39SAndroid Build Coastguard Worker * Converter implementation function(s) for ucnv_toUnicode(). 82*0e209d39SAndroid Build Coastguard Worker * If the toUnicodeWithOffsets function pointer is NULL, 83*0e209d39SAndroid Build Coastguard Worker * then the toUnicode function will be used and the offsets will be set to -1. 84*0e209d39SAndroid Build Coastguard Worker * 85*0e209d39SAndroid Build Coastguard Worker * Must maintain state across buffers. Use toUBytes[toULength] for partial input 86*0e209d39SAndroid Build Coastguard Worker * sequences; it will be checked in ucnv.c at the end of the input stream 87*0e209d39SAndroid Build Coastguard Worker * to detect truncated input. 88*0e209d39SAndroid Build Coastguard Worker * Some converters may need additional detection and may then set U_TRUNCATED_CHAR_FOUND. 89*0e209d39SAndroid Build Coastguard Worker * 90*0e209d39SAndroid Build Coastguard Worker * The toUnicodeWithOffsets must write exactly as many offset values as target 91*0e209d39SAndroid Build Coastguard Worker * units. Write offset values of -1 for when the source index corresponding to 92*0e209d39SAndroid Build Coastguard Worker * the output unit is not known (e.g., the character started in an earlier buffer). 93*0e209d39SAndroid Build Coastguard Worker * The pArgs->offsets pointer need not be moved forward. 94*0e209d39SAndroid Build Coastguard Worker * 95*0e209d39SAndroid Build Coastguard Worker * At function return, either one of the following conditions must be true: 96*0e209d39SAndroid Build Coastguard Worker * - U_BUFFER_OVERFLOW_ERROR and the target is full: target==targetLimit 97*0e209d39SAndroid Build Coastguard Worker * - another error code with toUBytes[toULength] set to the offending input 98*0e209d39SAndroid Build Coastguard Worker * - no error, and the source is consumed: source==sourceLimit 99*0e209d39SAndroid Build Coastguard Worker * 100*0e209d39SAndroid Build Coastguard Worker * The ucnv.c code will handle the end of the input (reset) 101*0e209d39SAndroid Build Coastguard Worker * (reset, and truncation detection) and callbacks. 102*0e209d39SAndroid Build Coastguard Worker */ 103*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterToUnicode) (UConverterToUnicodeArgs *, UErrorCode *); 104*0e209d39SAndroid Build Coastguard Worker 105*0e209d39SAndroid Build Coastguard Worker /* 106*0e209d39SAndroid Build Coastguard Worker * Same rules as for UConverterToUnicode. 107*0e209d39SAndroid Build Coastguard Worker * A lead surrogate is kept in fromUChar32 across buffers, and if an error 108*0e209d39SAndroid Build Coastguard Worker * occurs, then the offending input code point must be put into fromUChar32 109*0e209d39SAndroid Build Coastguard Worker * as well. 110*0e209d39SAndroid Build Coastguard Worker */ 111*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterFromUnicode) (UConverterFromUnicodeArgs *, UErrorCode *); 112*0e209d39SAndroid Build Coastguard Worker 113*0e209d39SAndroid Build Coastguard Worker /* 114*0e209d39SAndroid Build Coastguard Worker * Converter implementation function for ucnv_convertEx(), for direct conversion 115*0e209d39SAndroid Build Coastguard Worker * between two charsets without pivoting through UTF-16. 116*0e209d39SAndroid Build Coastguard Worker * The rules are the same as for UConverterToUnicode and UConverterFromUnicode. 117*0e209d39SAndroid Build Coastguard Worker * In addition, 118*0e209d39SAndroid Build Coastguard Worker * - The toUnicode side must behave and keep state exactly like the 119*0e209d39SAndroid Build Coastguard Worker * UConverterToUnicode implementation for the same source charset. 120*0e209d39SAndroid Build Coastguard Worker * - A U_USING_DEFAULT_WARNING can be set to request to temporarily fall back 121*0e209d39SAndroid Build Coastguard Worker * to pivoting. When this function is called, the conversion framework makes 122*0e209d39SAndroid Build Coastguard Worker * sure that this warning is not set on input. 123*0e209d39SAndroid Build Coastguard Worker * - Continuing a partial match and flushing the toUnicode replay buffer 124*0e209d39SAndroid Build Coastguard Worker * are handled by pivoting, using the toUnicode and fromUnicode functions. 125*0e209d39SAndroid Build Coastguard Worker */ 126*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterConvert) (UConverterFromUnicodeArgs *pFromUArgs, 127*0e209d39SAndroid Build Coastguard Worker UConverterToUnicodeArgs *pToUArgs, 128*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 129*0e209d39SAndroid Build Coastguard Worker 130*0e209d39SAndroid Build Coastguard Worker /* 131*0e209d39SAndroid Build Coastguard Worker * Converter implementation function for ucnv_getNextUChar(). 132*0e209d39SAndroid Build Coastguard Worker * If the function pointer is NULL, then the toUnicode function will be used. 133*0e209d39SAndroid Build Coastguard Worker * 134*0e209d39SAndroid Build Coastguard Worker * Will be called at a character boundary (toULength==0). 135*0e209d39SAndroid Build Coastguard Worker * May return with 136*0e209d39SAndroid Build Coastguard Worker * - U_INDEX_OUTOFBOUNDS_ERROR if there was no output for the input 137*0e209d39SAndroid Build Coastguard Worker * (the return value will be ignored) 138*0e209d39SAndroid Build Coastguard Worker * - U_TRUNCATED_CHAR_FOUND or another error code (never U_BUFFER_OVERFLOW_ERROR!) 139*0e209d39SAndroid Build Coastguard Worker * with toUBytes[toULength] set to the offending input 140*0e209d39SAndroid Build Coastguard Worker * (the return value will be ignored) 141*0e209d39SAndroid Build Coastguard Worker * - return UCNV_GET_NEXT_UCHAR_USE_TO_U, without moving the source pointer, 142*0e209d39SAndroid Build Coastguard Worker * to indicate that the ucnv.c code shall call the toUnicode function instead 143*0e209d39SAndroid Build Coastguard Worker * - return a real code point result 144*0e209d39SAndroid Build Coastguard Worker * 145*0e209d39SAndroid Build Coastguard Worker * Unless UCNV_GET_NEXT_UCHAR_USE_TO_U is returned, the source bytes must be consumed. 146*0e209d39SAndroid Build Coastguard Worker * 147*0e209d39SAndroid Build Coastguard Worker * The ucnv.c code will handle the end of the input (reset) 148*0e209d39SAndroid Build Coastguard Worker * (except for truncation detection!) and callbacks. 149*0e209d39SAndroid Build Coastguard Worker */ 150*0e209d39SAndroid Build Coastguard Worker typedef UChar32 (*UConverterGetNextUChar) (UConverterToUnicodeArgs *, UErrorCode *); 151*0e209d39SAndroid Build Coastguard Worker 152*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterGetStarters)(const UConverter* converter, 153*0e209d39SAndroid Build Coastguard Worker UBool starters[256], 154*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 155*0e209d39SAndroid Build Coastguard Worker 156*0e209d39SAndroid Build Coastguard Worker /* If this function pointer is null or if the function returns null 157*0e209d39SAndroid Build Coastguard Worker * the name field in static data struct should be returned by 158*0e209d39SAndroid Build Coastguard Worker * ucnv_getName() API function 159*0e209d39SAndroid Build Coastguard Worker */ 160*0e209d39SAndroid Build Coastguard Worker typedef const char * (*UConverterGetName) (const UConverter *cnv); 161*0e209d39SAndroid Build Coastguard Worker 162*0e209d39SAndroid Build Coastguard Worker /** 163*0e209d39SAndroid Build Coastguard Worker * Write the codepage substitution character. 164*0e209d39SAndroid Build Coastguard Worker * If this function is not set, then ucnv_cbFromUWriteSub() writes 165*0e209d39SAndroid Build Coastguard Worker * the substitution character from UConverter. 166*0e209d39SAndroid Build Coastguard Worker * For stateful converters, it is typically necessary to handle this 167*0e209d39SAndroid Build Coastguard Worker * specifically for the converter in order to properly maintain the state. 168*0e209d39SAndroid Build Coastguard Worker */ 169*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterWriteSub) (UConverterFromUnicodeArgs *pArgs, int32_t offsetIndex, UErrorCode *pErrorCode); 170*0e209d39SAndroid Build Coastguard Worker 171*0e209d39SAndroid Build Coastguard Worker /** 172*0e209d39SAndroid Build Coastguard Worker * For converter-specific safeClone processing 173*0e209d39SAndroid Build Coastguard Worker * If this function is not set, then ucnv_safeClone assumes that the converter has no private data that changes 174*0e209d39SAndroid Build Coastguard Worker * after the converter is done opening. 175*0e209d39SAndroid Build Coastguard Worker * If this function is set, then it is called just after a memcpy() of 176*0e209d39SAndroid Build Coastguard Worker * converter data to the new, empty converter, and is expected to set up 177*0e209d39SAndroid Build Coastguard Worker * the initial state of the converter. It is not expected to increment the 178*0e209d39SAndroid Build Coastguard Worker * reference counts of the standard data types such as the shared data. 179*0e209d39SAndroid Build Coastguard Worker */ 180*0e209d39SAndroid Build Coastguard Worker typedef UConverter * (*UConverterSafeClone) (const UConverter *cnv, 181*0e209d39SAndroid Build Coastguard Worker void *stackBuffer, 182*0e209d39SAndroid Build Coastguard Worker int32_t *pBufferSize, 183*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 184*0e209d39SAndroid Build Coastguard Worker 185*0e209d39SAndroid Build Coastguard Worker /** 186*0e209d39SAndroid Build Coastguard Worker * Filters for some ucnv_getUnicodeSet() implementation code. 187*0e209d39SAndroid Build Coastguard Worker */ 188*0e209d39SAndroid Build Coastguard Worker typedef enum UConverterSetFilter { 189*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_NONE, 190*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_DBCS_ONLY, 191*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_2022_CN, 192*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_SJIS, 193*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_GR94DBCS, 194*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_HZ, 195*0e209d39SAndroid Build Coastguard Worker UCNV_SET_FILTER_COUNT 196*0e209d39SAndroid Build Coastguard Worker } UConverterSetFilter; 197*0e209d39SAndroid Build Coastguard Worker 198*0e209d39SAndroid Build Coastguard Worker /** 199*0e209d39SAndroid Build Coastguard Worker * Fills the set of Unicode code points that can be converted by an ICU converter. 200*0e209d39SAndroid Build Coastguard Worker * The API function ucnv_getUnicodeSet() clears the USet before calling 201*0e209d39SAndroid Build Coastguard Worker * the converter's getUnicodeSet() implementation; the converter should only 202*0e209d39SAndroid Build Coastguard Worker * add the appropriate code points to allow recursive use. 203*0e209d39SAndroid Build Coastguard Worker * For example, the ISO-2022-JP converter will call each subconverter's 204*0e209d39SAndroid Build Coastguard Worker * getUnicodeSet() implementation to consecutively add code points to 205*0e209d39SAndroid Build Coastguard Worker * the same USet, which will result in a union of the sets of all subconverters. 206*0e209d39SAndroid Build Coastguard Worker * 207*0e209d39SAndroid Build Coastguard Worker * For more documentation, see ucnv_getUnicodeSet() in ucnv.h. 208*0e209d39SAndroid Build Coastguard Worker */ 209*0e209d39SAndroid Build Coastguard Worker typedef void (*UConverterGetUnicodeSet) (const UConverter *cnv, 210*0e209d39SAndroid Build Coastguard Worker const USetAdder *sa, 211*0e209d39SAndroid Build Coastguard Worker UConverterUnicodeSet which, 212*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 213*0e209d39SAndroid Build Coastguard Worker 214*0e209d39SAndroid Build Coastguard Worker UBool CONVERSION_U_SUCCESS (UErrorCode err); 215*0e209d39SAndroid Build Coastguard Worker 216*0e209d39SAndroid Build Coastguard Worker /** 217*0e209d39SAndroid Build Coastguard Worker * UConverterImpl contains all the data and functions for a converter type. 218*0e209d39SAndroid Build Coastguard Worker * Its function pointers work much like a C++ vtable. 219*0e209d39SAndroid Build Coastguard Worker * Many converter types need to define only a subset of the functions; 220*0e209d39SAndroid Build Coastguard Worker * when a function pointer is NULL, then a default action will be performed. 221*0e209d39SAndroid Build Coastguard Worker * 222*0e209d39SAndroid Build Coastguard Worker * Every converter type must implement toUnicode, fromUnicode, and getNextUChar, 223*0e209d39SAndroid Build Coastguard Worker * otherwise the converter may crash. 224*0e209d39SAndroid Build Coastguard Worker * Every converter type that has variable-length codepage sequences should 225*0e209d39SAndroid Build Coastguard Worker * also implement toUnicodeWithOffsets and fromUnicodeWithOffsets for 226*0e209d39SAndroid Build Coastguard Worker * correct offset handling. 227*0e209d39SAndroid Build Coastguard Worker * All other functions may or may not be implemented - it depends only on 228*0e209d39SAndroid Build Coastguard Worker * whether the converter type needs them. 229*0e209d39SAndroid Build Coastguard Worker * 230*0e209d39SAndroid Build Coastguard Worker * When open() fails, then close() will be called, if present. 231*0e209d39SAndroid Build Coastguard Worker */ 232*0e209d39SAndroid Build Coastguard Worker struct UConverterImpl { 233*0e209d39SAndroid Build Coastguard Worker UConverterType type; 234*0e209d39SAndroid Build Coastguard Worker 235*0e209d39SAndroid Build Coastguard Worker UConverterLoad load; 236*0e209d39SAndroid Build Coastguard Worker UConverterUnload unload; 237*0e209d39SAndroid Build Coastguard Worker 238*0e209d39SAndroid Build Coastguard Worker UConverterOpen open; 239*0e209d39SAndroid Build Coastguard Worker UConverterClose close; 240*0e209d39SAndroid Build Coastguard Worker UConverterReset reset; 241*0e209d39SAndroid Build Coastguard Worker 242*0e209d39SAndroid Build Coastguard Worker UConverterToUnicode toUnicode; 243*0e209d39SAndroid Build Coastguard Worker UConverterToUnicode toUnicodeWithOffsets; 244*0e209d39SAndroid Build Coastguard Worker UConverterFromUnicode fromUnicode; 245*0e209d39SAndroid Build Coastguard Worker UConverterFromUnicode fromUnicodeWithOffsets; 246*0e209d39SAndroid Build Coastguard Worker UConverterGetNextUChar getNextUChar; 247*0e209d39SAndroid Build Coastguard Worker 248*0e209d39SAndroid Build Coastguard Worker UConverterGetStarters getStarters; 249*0e209d39SAndroid Build Coastguard Worker UConverterGetName getName; 250*0e209d39SAndroid Build Coastguard Worker UConverterWriteSub writeSub; 251*0e209d39SAndroid Build Coastguard Worker UConverterSafeClone safeClone; 252*0e209d39SAndroid Build Coastguard Worker UConverterGetUnicodeSet getUnicodeSet; 253*0e209d39SAndroid Build Coastguard Worker 254*0e209d39SAndroid Build Coastguard Worker UConverterConvert toUTF8; 255*0e209d39SAndroid Build Coastguard Worker UConverterConvert fromUTF8; 256*0e209d39SAndroid Build Coastguard Worker }; 257*0e209d39SAndroid Build Coastguard Worker 258*0e209d39SAndroid Build Coastguard Worker extern const UConverterSharedData 259*0e209d39SAndroid Build Coastguard Worker _MBCSData, _Latin1Data, 260*0e209d39SAndroid Build Coastguard Worker _UTF8Data, _UTF16BEData, _UTF16LEData, _UTF32BEData, _UTF32LEData, 261*0e209d39SAndroid Build Coastguard Worker _ISO2022Data, 262*0e209d39SAndroid Build Coastguard Worker _LMBCSData1,_LMBCSData2, _LMBCSData3, _LMBCSData4, _LMBCSData5, _LMBCSData6, 263*0e209d39SAndroid Build Coastguard Worker _LMBCSData8,_LMBCSData11,_LMBCSData16,_LMBCSData17,_LMBCSData18,_LMBCSData19, 264*0e209d39SAndroid Build Coastguard Worker _HZData,_ISCIIData, _SCSUData, _ASCIIData, 265*0e209d39SAndroid Build Coastguard Worker _UTF7Data, _Bocu1Data, _UTF16Data, _UTF32Data, _CESU8Data, _IMAPData, _CompoundTextData; 266*0e209d39SAndroid Build Coastguard Worker 267*0e209d39SAndroid Build Coastguard Worker U_CDECL_END 268*0e209d39SAndroid Build Coastguard Worker 269*0e209d39SAndroid Build Coastguard Worker /** Always use fallbacks from codepage to Unicode */ 270*0e209d39SAndroid Build Coastguard Worker #define TO_U_USE_FALLBACK(useFallback) true 271*0e209d39SAndroid Build Coastguard Worker #define UCNV_TO_U_USE_FALLBACK(cnv) true 272*0e209d39SAndroid Build Coastguard Worker 273*0e209d39SAndroid Build Coastguard Worker /** Use fallbacks from Unicode to codepage when cnv->useFallback or for private-use code points */ 274*0e209d39SAndroid Build Coastguard Worker #define IS_PRIVATE_USE(c) ((uint32_t)((c)-0xe000)<0x1900 || (uint32_t)((c)-0xf0000)<0x20000) 275*0e209d39SAndroid Build Coastguard Worker #define FROM_U_USE_FALLBACK(useFallback, c) ((useFallback) || IS_PRIVATE_USE(c)) 276*0e209d39SAndroid Build Coastguard Worker #define UCNV_FROM_U_USE_FALLBACK(cnv, c) FROM_U_USE_FALLBACK((cnv)->useFallback, c) 277*0e209d39SAndroid Build Coastguard Worker 278*0e209d39SAndroid Build Coastguard Worker /** 279*0e209d39SAndroid Build Coastguard Worker * Magic number for ucnv_getNextUChar(), returned by a 280*0e209d39SAndroid Build Coastguard Worker * getNextUChar() implementation to indicate to use the converter's toUnicode() 281*0e209d39SAndroid Build Coastguard Worker * instead of the native function. 282*0e209d39SAndroid Build Coastguard Worker * @internal 283*0e209d39SAndroid Build Coastguard Worker */ 284*0e209d39SAndroid Build Coastguard Worker #define UCNV_GET_NEXT_UCHAR_USE_TO_U -9 285*0e209d39SAndroid Build Coastguard Worker 286*0e209d39SAndroid Build Coastguard Worker U_CFUNC void 287*0e209d39SAndroid Build Coastguard Worker ucnv_getCompleteUnicodeSet(const UConverter *cnv, 288*0e209d39SAndroid Build Coastguard Worker const USetAdder *sa, 289*0e209d39SAndroid Build Coastguard Worker UConverterUnicodeSet which, 290*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 291*0e209d39SAndroid Build Coastguard Worker 292*0e209d39SAndroid Build Coastguard Worker U_CFUNC void 293*0e209d39SAndroid Build Coastguard Worker ucnv_getNonSurrogateUnicodeSet(const UConverter *cnv, 294*0e209d39SAndroid Build Coastguard Worker const USetAdder *sa, 295*0e209d39SAndroid Build Coastguard Worker UConverterUnicodeSet which, 296*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 297*0e209d39SAndroid Build Coastguard Worker 298*0e209d39SAndroid Build Coastguard Worker U_CFUNC void 299*0e209d39SAndroid Build Coastguard Worker ucnv_fromUWriteBytes(UConverter *cnv, 300*0e209d39SAndroid Build Coastguard Worker const char *bytes, int32_t length, 301*0e209d39SAndroid Build Coastguard Worker char **target, const char *targetLimit, 302*0e209d39SAndroid Build Coastguard Worker int32_t **offsets, 303*0e209d39SAndroid Build Coastguard Worker int32_t sourceIndex, 304*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 305*0e209d39SAndroid Build Coastguard Worker U_CFUNC void 306*0e209d39SAndroid Build Coastguard Worker ucnv_toUWriteUChars(UConverter *cnv, 307*0e209d39SAndroid Build Coastguard Worker const UChar *uchars, int32_t length, 308*0e209d39SAndroid Build Coastguard Worker UChar **target, const UChar *targetLimit, 309*0e209d39SAndroid Build Coastguard Worker int32_t **offsets, 310*0e209d39SAndroid Build Coastguard Worker int32_t sourceIndex, 311*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 312*0e209d39SAndroid Build Coastguard Worker 313*0e209d39SAndroid Build Coastguard Worker U_CFUNC void 314*0e209d39SAndroid Build Coastguard Worker ucnv_toUWriteCodePoint(UConverter *cnv, 315*0e209d39SAndroid Build Coastguard Worker UChar32 c, 316*0e209d39SAndroid Build Coastguard Worker UChar **target, const UChar *targetLimit, 317*0e209d39SAndroid Build Coastguard Worker int32_t **offsets, 318*0e209d39SAndroid Build Coastguard Worker int32_t sourceIndex, 319*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 320*0e209d39SAndroid Build Coastguard Worker 321*0e209d39SAndroid Build Coastguard Worker #endif 322*0e209d39SAndroid Build Coastguard Worker 323*0e209d39SAndroid Build Coastguard Worker #endif /* UCNV_CNV */ 324