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-2009, 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 * 10*0e209d39SAndroid Build Coastguard Worker * ucnv_err.h: 11*0e209d39SAndroid Build Coastguard Worker */ 12*0e209d39SAndroid Build Coastguard Worker 13*0e209d39SAndroid Build Coastguard Worker /** 14*0e209d39SAndroid Build Coastguard Worker * \file 15*0e209d39SAndroid Build Coastguard Worker * \brief C API: UConverter predefined error callbacks 16*0e209d39SAndroid Build Coastguard Worker * 17*0e209d39SAndroid Build Coastguard Worker * <h2>Error Behaviour Functions</h2> 18*0e209d39SAndroid Build Coastguard Worker * Defines some error behaviour functions called by ucnv_{from,to}Unicode 19*0e209d39SAndroid Build Coastguard Worker * These are provided as part of ICU and many are stable, but they 20*0e209d39SAndroid Build Coastguard Worker * can also be considered only as an example of what can be done with 21*0e209d39SAndroid Build Coastguard Worker * callbacks. You may of course write your own. 22*0e209d39SAndroid Build Coastguard Worker * 23*0e209d39SAndroid Build Coastguard Worker * If you want to write your own, you may also find the functions from 24*0e209d39SAndroid Build Coastguard Worker * ucnv_cb.h useful when writing your own callbacks. 25*0e209d39SAndroid Build Coastguard Worker * 26*0e209d39SAndroid Build Coastguard Worker * These functions, although public, should NEVER be called directly. 27*0e209d39SAndroid Build Coastguard Worker * They should be used as parameters to the ucnv_setFromUCallback 28*0e209d39SAndroid Build Coastguard Worker * and ucnv_setToUCallback functions, to set the behaviour of a converter 29*0e209d39SAndroid Build Coastguard Worker * when it encounters ILLEGAL/UNMAPPED/INVALID sequences. 30*0e209d39SAndroid Build Coastguard Worker * 31*0e209d39SAndroid Build Coastguard Worker * usage example: 'STOP' doesn't need any context, but newContext 32*0e209d39SAndroid Build Coastguard Worker * could be set to something other than 'NULL' if needed. The available 33*0e209d39SAndroid Build Coastguard Worker * contexts in this header can modify the default behavior of the callback. 34*0e209d39SAndroid Build Coastguard Worker * 35*0e209d39SAndroid Build Coastguard Worker * \code 36*0e209d39SAndroid Build Coastguard Worker * UErrorCode err = U_ZERO_ERROR; 37*0e209d39SAndroid Build Coastguard Worker * UConverter *myConverter = ucnv_open("ibm-949", &err); 38*0e209d39SAndroid Build Coastguard Worker * const void *oldContext; 39*0e209d39SAndroid Build Coastguard Worker * UConverterFromUCallback oldAction; 40*0e209d39SAndroid Build Coastguard Worker * 41*0e209d39SAndroid Build Coastguard Worker * 42*0e209d39SAndroid Build Coastguard Worker * if (U_SUCCESS(err)) 43*0e209d39SAndroid Build Coastguard Worker * { 44*0e209d39SAndroid Build Coastguard Worker * ucnv_setFromUCallBack(myConverter, 45*0e209d39SAndroid Build Coastguard Worker * UCNV_FROM_U_CALLBACK_STOP, 46*0e209d39SAndroid Build Coastguard Worker * NULL, 47*0e209d39SAndroid Build Coastguard Worker * &oldAction, 48*0e209d39SAndroid Build Coastguard Worker * &oldContext, 49*0e209d39SAndroid Build Coastguard Worker * &status); 50*0e209d39SAndroid Build Coastguard Worker * } 51*0e209d39SAndroid Build Coastguard Worker * \endcode 52*0e209d39SAndroid Build Coastguard Worker * 53*0e209d39SAndroid Build Coastguard Worker * The code above tells "myConverter" to stop when it encounters an 54*0e209d39SAndroid Build Coastguard Worker * ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from 55*0e209d39SAndroid Build Coastguard Worker * Unicode -> Codepage. The behavior from Codepage to Unicode is not changed, 56*0e209d39SAndroid Build Coastguard Worker * and ucnv_setToUCallBack would need to be called in order to change 57*0e209d39SAndroid Build Coastguard Worker * that behavior too. 58*0e209d39SAndroid Build Coastguard Worker * 59*0e209d39SAndroid Build Coastguard Worker * Here is an example with a context: 60*0e209d39SAndroid Build Coastguard Worker * 61*0e209d39SAndroid Build Coastguard Worker * \code 62*0e209d39SAndroid Build Coastguard Worker * UErrorCode err = U_ZERO_ERROR; 63*0e209d39SAndroid Build Coastguard Worker * UConverter *myConverter = ucnv_open("ibm-949", &err); 64*0e209d39SAndroid Build Coastguard Worker * const void *oldContext; 65*0e209d39SAndroid Build Coastguard Worker * UConverterFromUCallback oldAction; 66*0e209d39SAndroid Build Coastguard Worker * 67*0e209d39SAndroid Build Coastguard Worker * 68*0e209d39SAndroid Build Coastguard Worker * if (U_SUCCESS(err)) 69*0e209d39SAndroid Build Coastguard Worker * { 70*0e209d39SAndroid Build Coastguard Worker * ucnv_setToUCallBack(myConverter, 71*0e209d39SAndroid Build Coastguard Worker * UCNV_TO_U_CALLBACK_SUBSTITUTE, 72*0e209d39SAndroid Build Coastguard Worker * UCNV_SUB_STOP_ON_ILLEGAL, 73*0e209d39SAndroid Build Coastguard Worker * &oldAction, 74*0e209d39SAndroid Build Coastguard Worker * &oldContext, 75*0e209d39SAndroid Build Coastguard Worker * &status); 76*0e209d39SAndroid Build Coastguard Worker * } 77*0e209d39SAndroid Build Coastguard Worker * \endcode 78*0e209d39SAndroid Build Coastguard Worker * 79*0e209d39SAndroid Build Coastguard Worker * The code above tells "myConverter" to stop when it encounters an 80*0e209d39SAndroid Build Coastguard Worker * ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from 81*0e209d39SAndroid Build Coastguard Worker * Codepage -> Unicode. Any unmapped and legal characters will be 82*0e209d39SAndroid Build Coastguard Worker * substituted to be the default substitution character. 83*0e209d39SAndroid Build Coastguard Worker */ 84*0e209d39SAndroid Build Coastguard Worker 85*0e209d39SAndroid Build Coastguard Worker #ifndef UCNV_ERR_H 86*0e209d39SAndroid Build Coastguard Worker #define UCNV_ERR_H 87*0e209d39SAndroid Build Coastguard Worker 88*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 89*0e209d39SAndroid Build Coastguard Worker 90*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_CONVERSION 91*0e209d39SAndroid Build Coastguard Worker 92*0e209d39SAndroid Build Coastguard Worker /** Forward declaring the UConverter structure. @stable ICU 2.0 */ 93*0e209d39SAndroid Build Coastguard Worker struct UConverter; 94*0e209d39SAndroid Build Coastguard Worker 95*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 2.0 */ 96*0e209d39SAndroid Build Coastguard Worker typedef struct UConverter UConverter; 97*0e209d39SAndroid Build Coastguard Worker 98*0e209d39SAndroid Build Coastguard Worker /** 99*0e209d39SAndroid Build Coastguard Worker * FROM_U, TO_U context options for sub callback 100*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 101*0e209d39SAndroid Build Coastguard Worker */ 102*0e209d39SAndroid Build Coastguard Worker #define UCNV_SUB_STOP_ON_ILLEGAL "i" 103*0e209d39SAndroid Build Coastguard Worker 104*0e209d39SAndroid Build Coastguard Worker /** 105*0e209d39SAndroid Build Coastguard Worker * FROM_U, TO_U context options for skip callback 106*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 107*0e209d39SAndroid Build Coastguard Worker */ 108*0e209d39SAndroid Build Coastguard Worker #define UCNV_SKIP_STOP_ON_ILLEGAL "i" 109*0e209d39SAndroid Build Coastguard Worker 110*0e209d39SAndroid Build Coastguard Worker /** 111*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX) 112*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 113*0e209d39SAndroid Build Coastguard Worker */ 114*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_ICU NULL 115*0e209d39SAndroid Build Coastguard Worker /** 116*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\\uXXXX) 117*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 118*0e209d39SAndroid Build Coastguard Worker */ 119*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_JAVA "J" 120*0e209d39SAndroid Build Coastguard Worker /** 121*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\\uXXXX \\UXXXXXXXX) 122*0e209d39SAndroid Build Coastguard Worker * TO_U_CALLBACK_ESCAPE option to escape the character value according to C (\\xXXXX) 123*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 124*0e209d39SAndroid Build Coastguard Worker */ 125*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_C "C" 126*0e209d39SAndroid Build Coastguard Worker /** 127*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape \htmlonly(&#DDDD;)\endhtmlonly 128*0e209d39SAndroid Build Coastguard Worker * TO_U_CALLBACK_ESCAPE context option to escape the character value according to XML Decimal escape \htmlonly(&#DDDD;)\endhtmlonly 129*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 130*0e209d39SAndroid Build Coastguard Worker */ 131*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_XML_DEC "D" 132*0e209d39SAndroid Build Coastguard Worker /** 133*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape \htmlonly(&#xXXXX;)\endhtmlonly 134*0e209d39SAndroid Build Coastguard Worker * TO_U_CALLBACK_ESCAPE context option to escape the character value according to XML Hex escape \htmlonly(&#xXXXX;)\endhtmlonly 135*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 136*0e209d39SAndroid Build Coastguard Worker */ 137*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_XML_HEX "X" 138*0e209d39SAndroid Build Coastguard Worker /** 139*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to Unicode (U+XXXXX) 140*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 141*0e209d39SAndroid Build Coastguard Worker */ 142*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_UNICODE "U" 143*0e209d39SAndroid Build Coastguard Worker 144*0e209d39SAndroid Build Coastguard Worker /** 145*0e209d39SAndroid Build Coastguard Worker * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to CSS2 conventions (\\HH..H<space>, that is, 146*0e209d39SAndroid Build Coastguard Worker * a backslash, 1..6 hex digits, and a space) 147*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 148*0e209d39SAndroid Build Coastguard Worker */ 149*0e209d39SAndroid Build Coastguard Worker #define UCNV_ESCAPE_CSS2 "S" 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker /** 152*0e209d39SAndroid Build Coastguard Worker * The process condition code to be used with the callbacks. 153*0e209d39SAndroid Build Coastguard Worker * Codes which are greater than UCNV_IRREGULAR should be 154*0e209d39SAndroid Build Coastguard Worker * passed on to any chained callbacks. 155*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 156*0e209d39SAndroid Build Coastguard Worker */ 157*0e209d39SAndroid Build Coastguard Worker typedef enum { 158*0e209d39SAndroid Build Coastguard Worker UCNV_UNASSIGNED = 0, /**< The code point is unassigned. 159*0e209d39SAndroid Build Coastguard Worker The error code U_INVALID_CHAR_FOUND will be set. */ 160*0e209d39SAndroid Build Coastguard Worker UCNV_ILLEGAL = 1, /**< The code point is illegal. For example, 161*0e209d39SAndroid Build Coastguard Worker \\x81\\x2E is illegal in SJIS because \\x2E 162*0e209d39SAndroid Build Coastguard Worker is not a valid trail byte for the \\x81 163*0e209d39SAndroid Build Coastguard Worker lead byte. 164*0e209d39SAndroid Build Coastguard Worker Also, starting with Unicode 3.0.1, non-shortest byte sequences 165*0e209d39SAndroid Build Coastguard Worker in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061) 166*0e209d39SAndroid Build Coastguard Worker are also illegal, not just irregular. 167*0e209d39SAndroid Build Coastguard Worker The error code U_ILLEGAL_CHAR_FOUND will be set. */ 168*0e209d39SAndroid Build Coastguard Worker UCNV_IRREGULAR = 2, /**< The codepoint is not a regular sequence in 169*0e209d39SAndroid Build Coastguard Worker the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF 170*0e209d39SAndroid Build Coastguard Worker are irregular UTF-8 byte sequences for single surrogate 171*0e209d39SAndroid Build Coastguard Worker code points. 172*0e209d39SAndroid Build Coastguard Worker The error code U_INVALID_CHAR_FOUND will be set. */ 173*0e209d39SAndroid Build Coastguard Worker UCNV_RESET = 3, /**< The callback is called with this reason when a 174*0e209d39SAndroid Build Coastguard Worker 'reset' has occurred. Callback should reset all 175*0e209d39SAndroid Build Coastguard Worker state. */ 176*0e209d39SAndroid Build Coastguard Worker UCNV_CLOSE = 4, /**< Called when the converter is closed. The 177*0e209d39SAndroid Build Coastguard Worker callback should release any allocated memory.*/ 178*0e209d39SAndroid Build Coastguard Worker UCNV_CLONE = 5 /**< Called when ucnv_safeClone() is called on the 179*0e209d39SAndroid Build Coastguard Worker converter. the pointer available as the 180*0e209d39SAndroid Build Coastguard Worker 'context' is an alias to the original converters' 181*0e209d39SAndroid Build Coastguard Worker context pointer. If the context must be owned 182*0e209d39SAndroid Build Coastguard Worker by the new converter, the callback must clone 183*0e209d39SAndroid Build Coastguard Worker the data and call ucnv_setFromUCallback 184*0e209d39SAndroid Build Coastguard Worker (or setToUCallback) with the correct pointer. 185*0e209d39SAndroid Build Coastguard Worker @stable ICU 2.2 186*0e209d39SAndroid Build Coastguard Worker */ 187*0e209d39SAndroid Build Coastguard Worker } UConverterCallbackReason; 188*0e209d39SAndroid Build Coastguard Worker 189*0e209d39SAndroid Build Coastguard Worker 190*0e209d39SAndroid Build Coastguard Worker /** 191*0e209d39SAndroid Build Coastguard Worker * The structure for the fromUnicode callback function parameter. 192*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 193*0e209d39SAndroid Build Coastguard Worker */ 194*0e209d39SAndroid Build Coastguard Worker typedef struct { 195*0e209d39SAndroid Build Coastguard Worker uint16_t size; /**< The size of this struct. @stable ICU 2.0 */ 196*0e209d39SAndroid Build Coastguard Worker UBool flush; /**< The internal state of converter will be reset and data flushed if set to true. @stable ICU 2.0 */ 197*0e209d39SAndroid Build Coastguard Worker UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */ 198*0e209d39SAndroid Build Coastguard Worker const UChar *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */ 199*0e209d39SAndroid Build Coastguard Worker const UChar *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */ 200*0e209d39SAndroid Build Coastguard Worker char *target; /**< Pointer to the target buffer. @stable ICU 2.0 */ 201*0e209d39SAndroid Build Coastguard Worker const char *targetLimit; /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0 */ 202*0e209d39SAndroid Build Coastguard Worker int32_t *offsets; /**< Pointer to the buffer that receives the offsets. *offset = blah ; offset++;. @stable ICU 2.0 */ 203*0e209d39SAndroid Build Coastguard Worker } UConverterFromUnicodeArgs; 204*0e209d39SAndroid Build Coastguard Worker 205*0e209d39SAndroid Build Coastguard Worker 206*0e209d39SAndroid Build Coastguard Worker /** 207*0e209d39SAndroid Build Coastguard Worker * The structure for the toUnicode callback function parameter. 208*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 209*0e209d39SAndroid Build Coastguard Worker */ 210*0e209d39SAndroid Build Coastguard Worker typedef struct { 211*0e209d39SAndroid Build Coastguard Worker uint16_t size; /**< The size of this struct @stable ICU 2.0 */ 212*0e209d39SAndroid Build Coastguard Worker UBool flush; /**< The internal state of converter will be reset and data flushed if set to true. @stable ICU 2.0 */ 213*0e209d39SAndroid Build Coastguard Worker UConverter *converter; /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */ 214*0e209d39SAndroid Build Coastguard Worker const char *source; /**< Pointer to the source source buffer. @stable ICU 2.0 */ 215*0e209d39SAndroid Build Coastguard Worker const char *sourceLimit; /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0 */ 216*0e209d39SAndroid Build Coastguard Worker UChar *target; /**< Pointer to the target buffer. @stable ICU 2.0 */ 217*0e209d39SAndroid Build Coastguard Worker const UChar *targetLimit; /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0 */ 218*0e209d39SAndroid Build Coastguard Worker int32_t *offsets; /**< Pointer to the buffer that receives the offsets. *offset = blah ; offset++;. @stable ICU 2.0 */ 219*0e209d39SAndroid Build Coastguard Worker } UConverterToUnicodeArgs; 220*0e209d39SAndroid Build Coastguard Worker 221*0e209d39SAndroid Build Coastguard Worker 222*0e209d39SAndroid Build Coastguard Worker /** 223*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 224*0e209d39SAndroid Build Coastguard Worker * This From Unicode callback STOPS at the ILLEGAL_SEQUENCE, 225*0e209d39SAndroid Build Coastguard Worker * returning the error code back to the caller immediately. 226*0e209d39SAndroid Build Coastguard Worker * 227*0e209d39SAndroid Build Coastguard Worker * @param context Pointer to the callback's private data 228*0e209d39SAndroid Build Coastguard Worker * @param fromUArgs Information about the conversion in progress 229*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence 230*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 231*0e209d39SAndroid Build Coastguard Worker * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. 232*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 233*0e209d39SAndroid Build Coastguard Worker * @param err This should always be set to a failure status prior to calling. 234*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 235*0e209d39SAndroid Build Coastguard Worker */ 236*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP ( 237*0e209d39SAndroid Build Coastguard Worker const void *context, 238*0e209d39SAndroid Build Coastguard Worker UConverterFromUnicodeArgs *fromUArgs, 239*0e209d39SAndroid Build Coastguard Worker const UChar* codeUnits, 240*0e209d39SAndroid Build Coastguard Worker int32_t length, 241*0e209d39SAndroid Build Coastguard Worker UChar32 codePoint, 242*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 243*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 244*0e209d39SAndroid Build Coastguard Worker 245*0e209d39SAndroid Build Coastguard Worker 246*0e209d39SAndroid Build Coastguard Worker 247*0e209d39SAndroid Build Coastguard Worker /** 248*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 249*0e209d39SAndroid Build Coastguard Worker * This To Unicode callback STOPS at the ILLEGAL_SEQUENCE, 250*0e209d39SAndroid Build Coastguard Worker * returning the error code back to the caller immediately. 251*0e209d39SAndroid Build Coastguard Worker * 252*0e209d39SAndroid Build Coastguard Worker * @param context Pointer to the callback's private data 253*0e209d39SAndroid Build Coastguard Worker * @param toUArgs Information about the conversion in progress 254*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' bytes of the concerned codepage sequence 255*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 256*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 257*0e209d39SAndroid Build Coastguard Worker * @param err This should always be set to a failure status prior to calling. 258*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 259*0e209d39SAndroid Build Coastguard Worker */ 260*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP ( 261*0e209d39SAndroid Build Coastguard Worker const void *context, 262*0e209d39SAndroid Build Coastguard Worker UConverterToUnicodeArgs *toUArgs, 263*0e209d39SAndroid Build Coastguard Worker const char* codeUnits, 264*0e209d39SAndroid Build Coastguard Worker int32_t length, 265*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 266*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 267*0e209d39SAndroid Build Coastguard Worker 268*0e209d39SAndroid Build Coastguard Worker /** 269*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 270*0e209d39SAndroid Build Coastguard Worker * This From Unicode callback skips any ILLEGAL_SEQUENCE, or 271*0e209d39SAndroid Build Coastguard Worker * skips only UNASSIGNED_SEQUENCE depending on the context parameter 272*0e209d39SAndroid Build Coastguard Worker * simply ignoring those characters. 273*0e209d39SAndroid Build Coastguard Worker * 274*0e209d39SAndroid Build Coastguard Worker * @param context The function currently recognizes the callback options: 275*0e209d39SAndroid Build Coastguard Worker * UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, 276*0e209d39SAndroid Build Coastguard Worker * returning the error code back to the caller immediately. 277*0e209d39SAndroid Build Coastguard Worker * NULL: Skips any ILLEGAL_SEQUENCE 278*0e209d39SAndroid Build Coastguard Worker * @param fromUArgs Information about the conversion in progress 279*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence 280*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 281*0e209d39SAndroid Build Coastguard Worker * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. 282*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 283*0e209d39SAndroid Build Coastguard Worker * @param err Return value will be set to success if the callback was handled, 284*0e209d39SAndroid Build Coastguard Worker * otherwise this value will be set to a failure status. 285*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 286*0e209d39SAndroid Build Coastguard Worker */ 287*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP ( 288*0e209d39SAndroid Build Coastguard Worker const void *context, 289*0e209d39SAndroid Build Coastguard Worker UConverterFromUnicodeArgs *fromUArgs, 290*0e209d39SAndroid Build Coastguard Worker const UChar* codeUnits, 291*0e209d39SAndroid Build Coastguard Worker int32_t length, 292*0e209d39SAndroid Build Coastguard Worker UChar32 codePoint, 293*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 294*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 295*0e209d39SAndroid Build Coastguard Worker 296*0e209d39SAndroid Build Coastguard Worker /** 297*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 298*0e209d39SAndroid Build Coastguard Worker * This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or 299*0e209d39SAndroid Build Coastguard Worker * UNASSIGNED_SEQUENCE depending on context parameter, with the 300*0e209d39SAndroid Build Coastguard Worker * current substitution string for the converter. This is the default 301*0e209d39SAndroid Build Coastguard Worker * callback. 302*0e209d39SAndroid Build Coastguard Worker * 303*0e209d39SAndroid Build Coastguard Worker * @param context The function currently recognizes the callback options: 304*0e209d39SAndroid Build Coastguard Worker * UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, 305*0e209d39SAndroid Build Coastguard Worker * returning the error code back to the caller immediately. 306*0e209d39SAndroid Build Coastguard Worker * NULL: Substitutes any ILLEGAL_SEQUENCE 307*0e209d39SAndroid Build Coastguard Worker * @param fromUArgs Information about the conversion in progress 308*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence 309*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 310*0e209d39SAndroid Build Coastguard Worker * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. 311*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 312*0e209d39SAndroid Build Coastguard Worker * @param err Return value will be set to success if the callback was handled, 313*0e209d39SAndroid Build Coastguard Worker * otherwise this value will be set to a failure status. 314*0e209d39SAndroid Build Coastguard Worker * @see ucnv_setSubstChars 315*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 316*0e209d39SAndroid Build Coastguard Worker */ 317*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE ( 318*0e209d39SAndroid Build Coastguard Worker const void *context, 319*0e209d39SAndroid Build Coastguard Worker UConverterFromUnicodeArgs *fromUArgs, 320*0e209d39SAndroid Build Coastguard Worker const UChar* codeUnits, 321*0e209d39SAndroid Build Coastguard Worker int32_t length, 322*0e209d39SAndroid Build Coastguard Worker UChar32 codePoint, 323*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 324*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 325*0e209d39SAndroid Build Coastguard Worker 326*0e209d39SAndroid Build Coastguard Worker /** 327*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 328*0e209d39SAndroid Build Coastguard Worker * This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the 329*0e209d39SAndroid Build Coastguard Worker * hexadecimal representation of the illegal codepoints 330*0e209d39SAndroid Build Coastguard Worker * 331*0e209d39SAndroid Build Coastguard Worker * @param context The function currently recognizes the callback options: 332*0e209d39SAndroid Build Coastguard Worker * <ul> 333*0e209d39SAndroid Build Coastguard Worker * <li>UCNV_ESCAPE_ICU: Substitutes the ILLEGAL SEQUENCE with the hexadecimal 334*0e209d39SAndroid Build Coastguard Worker * representation in the format %UXXXX, e.g. "%uFFFE%u00AC%uC8FE"). 335*0e209d39SAndroid Build Coastguard Worker * In the Event the converter doesn't support the characters {%,U}[A-F][0-9], 336*0e209d39SAndroid Build Coastguard Worker * it will substitute the illegal sequence with the substitution characters. 337*0e209d39SAndroid Build Coastguard Worker * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as 338*0e209d39SAndroid Build Coastguard Worker * %UD84D%UDC56</li> 339*0e209d39SAndroid Build Coastguard Worker * <li>UCNV_ESCAPE_JAVA: Substitutes the ILLEGAL SEQUENCE with the hexadecimal 340*0e209d39SAndroid Build Coastguard Worker * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). 341*0e209d39SAndroid Build Coastguard Worker * In the Event the converter doesn't support the characters {\,u}[A-F][0-9], 342*0e209d39SAndroid Build Coastguard Worker * it will substitute the illegal sequence with the substitution characters. 343*0e209d39SAndroid Build Coastguard Worker * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as 344*0e209d39SAndroid Build Coastguard Worker * \\uD84D\\uDC56</li> 345*0e209d39SAndroid Build Coastguard Worker * <li>UCNV_ESCAPE_C: Substitutes the ILLEGAL SEQUENCE with the hexadecimal 346*0e209d39SAndroid Build Coastguard Worker * representation in the format \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). 347*0e209d39SAndroid Build Coastguard Worker * In the Event the converter doesn't support the characters {\,u,U}[A-F][0-9], 348*0e209d39SAndroid Build Coastguard Worker * it will substitute the illegal sequence with the substitution characters. 349*0e209d39SAndroid Build Coastguard Worker * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as 350*0e209d39SAndroid Build Coastguard Worker * \\U00023456</li> 351*0e209d39SAndroid Build Coastguard Worker * <li>UCNV_ESCAPE_XML_DEC: Substitutes the ILLEGAL SEQUENCE with the decimal 352*0e209d39SAndroid Build Coastguard Worker * representation in the format \htmlonly&#DDDDDDDD;, e.g. "&#65534;&#172;&#51454;")\endhtmlonly. 353*0e209d39SAndroid Build Coastguard Worker * In the Event the converter doesn't support the characters {&,#}[0-9], 354*0e209d39SAndroid Build Coastguard Worker * it will substitute the illegal sequence with the substitution characters. 355*0e209d39SAndroid Build Coastguard Worker * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as 356*0e209d39SAndroid Build Coastguard Worker * &#144470; and Zero padding is ignored.</li> 357*0e209d39SAndroid Build Coastguard Worker * <li>UCNV_ESCAPE_XML_HEX:Substitutes the ILLEGAL SEQUENCE with the decimal 358*0e209d39SAndroid Build Coastguard Worker * representation in the format \htmlonly&#xXXXX; e.g. "&#xFFFE;&#x00AC;&#xC8FE;")\endhtmlonly. 359*0e209d39SAndroid Build Coastguard Worker * In the Event the converter doesn't support the characters {&,#,x}[0-9], 360*0e209d39SAndroid Build Coastguard Worker * it will substitute the illegal sequence with the substitution characters. 361*0e209d39SAndroid Build Coastguard Worker * Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as 362*0e209d39SAndroid Build Coastguard Worker * \htmlonly&#x23456;\endhtmlonly</li> 363*0e209d39SAndroid Build Coastguard Worker * </ul> 364*0e209d39SAndroid Build Coastguard Worker * @param fromUArgs Information about the conversion in progress 365*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence 366*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 367*0e209d39SAndroid Build Coastguard Worker * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. 368*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 369*0e209d39SAndroid Build Coastguard Worker * @param err Return value will be set to success if the callback was handled, 370*0e209d39SAndroid Build Coastguard Worker * otherwise this value will be set to a failure status. 371*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 372*0e209d39SAndroid Build Coastguard Worker */ 373*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE ( 374*0e209d39SAndroid Build Coastguard Worker const void *context, 375*0e209d39SAndroid Build Coastguard Worker UConverterFromUnicodeArgs *fromUArgs, 376*0e209d39SAndroid Build Coastguard Worker const UChar* codeUnits, 377*0e209d39SAndroid Build Coastguard Worker int32_t length, 378*0e209d39SAndroid Build Coastguard Worker UChar32 codePoint, 379*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 380*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 381*0e209d39SAndroid Build Coastguard Worker 382*0e209d39SAndroid Build Coastguard Worker 383*0e209d39SAndroid Build Coastguard Worker /** 384*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 385*0e209d39SAndroid Build Coastguard Worker * This To Unicode callback skips any ILLEGAL_SEQUENCE, or 386*0e209d39SAndroid Build Coastguard Worker * skips only UNASSIGNED_SEQUENCE depending on the context parameter 387*0e209d39SAndroid Build Coastguard Worker * simply ignoring those characters. 388*0e209d39SAndroid Build Coastguard Worker * 389*0e209d39SAndroid Build Coastguard Worker * @param context The function currently recognizes the callback options: 390*0e209d39SAndroid Build Coastguard Worker * UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, 391*0e209d39SAndroid Build Coastguard Worker * returning the error code back to the caller immediately. 392*0e209d39SAndroid Build Coastguard Worker * NULL: Skips any ILLEGAL_SEQUENCE 393*0e209d39SAndroid Build Coastguard Worker * @param toUArgs Information about the conversion in progress 394*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' bytes of the concerned codepage sequence 395*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 396*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 397*0e209d39SAndroid Build Coastguard Worker * @param err Return value will be set to success if the callback was handled, 398*0e209d39SAndroid Build Coastguard Worker * otherwise this value will be set to a failure status. 399*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 400*0e209d39SAndroid Build Coastguard Worker */ 401*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP ( 402*0e209d39SAndroid Build Coastguard Worker const void *context, 403*0e209d39SAndroid Build Coastguard Worker UConverterToUnicodeArgs *toUArgs, 404*0e209d39SAndroid Build Coastguard Worker const char* codeUnits, 405*0e209d39SAndroid Build Coastguard Worker int32_t length, 406*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 407*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 408*0e209d39SAndroid Build Coastguard Worker 409*0e209d39SAndroid Build Coastguard Worker /** 410*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 411*0e209d39SAndroid Build Coastguard Worker * This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or 412*0e209d39SAndroid Build Coastguard Worker * UNASSIGNED_SEQUENCE depending on context parameter, with the 413*0e209d39SAndroid Build Coastguard Worker * Unicode substitution character, U+FFFD. 414*0e209d39SAndroid Build Coastguard Worker * 415*0e209d39SAndroid Build Coastguard Worker * @param context The function currently recognizes the callback options: 416*0e209d39SAndroid Build Coastguard Worker * UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, 417*0e209d39SAndroid Build Coastguard Worker * returning the error code back to the caller immediately. 418*0e209d39SAndroid Build Coastguard Worker * NULL: Substitutes any ILLEGAL_SEQUENCE 419*0e209d39SAndroid Build Coastguard Worker * @param toUArgs Information about the conversion in progress 420*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' bytes of the concerned codepage sequence 421*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 422*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 423*0e209d39SAndroid Build Coastguard Worker * @param err Return value will be set to success if the callback was handled, 424*0e209d39SAndroid Build Coastguard Worker * otherwise this value will be set to a failure status. 425*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 426*0e209d39SAndroid Build Coastguard Worker */ 427*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE ( 428*0e209d39SAndroid Build Coastguard Worker const void *context, 429*0e209d39SAndroid Build Coastguard Worker UConverterToUnicodeArgs *toUArgs, 430*0e209d39SAndroid Build Coastguard Worker const char* codeUnits, 431*0e209d39SAndroid Build Coastguard Worker int32_t length, 432*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 433*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 434*0e209d39SAndroid Build Coastguard Worker 435*0e209d39SAndroid Build Coastguard Worker /** 436*0e209d39SAndroid Build Coastguard Worker * DO NOT CALL THIS FUNCTION DIRECTLY! 437*0e209d39SAndroid Build Coastguard Worker * This To Unicode callback will Substitute the ILLEGAL SEQUENCE with the 438*0e209d39SAndroid Build Coastguard Worker * hexadecimal representation of the illegal bytes 439*0e209d39SAndroid Build Coastguard Worker * (in the format %XNN, e.g. "%XFF%X0A%XC8%X03"). 440*0e209d39SAndroid Build Coastguard Worker * 441*0e209d39SAndroid Build Coastguard Worker * @param context This function currently recognizes the callback options: 442*0e209d39SAndroid Build Coastguard Worker * UCNV_ESCAPE_ICU, UCNV_ESCAPE_JAVA, UCNV_ESCAPE_C, UCNV_ESCAPE_XML_DEC, 443*0e209d39SAndroid Build Coastguard Worker * UCNV_ESCAPE_XML_HEX and UCNV_ESCAPE_UNICODE. 444*0e209d39SAndroid Build Coastguard Worker * @param toUArgs Information about the conversion in progress 445*0e209d39SAndroid Build Coastguard Worker * @param codeUnits Points to 'length' bytes of the concerned codepage sequence 446*0e209d39SAndroid Build Coastguard Worker * @param length Size (in bytes) of the concerned codepage sequence 447*0e209d39SAndroid Build Coastguard Worker * @param reason Defines the reason the callback was invoked 448*0e209d39SAndroid Build Coastguard Worker * @param err Return value will be set to success if the callback was handled, 449*0e209d39SAndroid Build Coastguard Worker * otherwise this value will be set to a failure status. 450*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 451*0e209d39SAndroid Build Coastguard Worker */ 452*0e209d39SAndroid Build Coastguard Worker 453*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE ( 454*0e209d39SAndroid Build Coastguard Worker const void *context, 455*0e209d39SAndroid Build Coastguard Worker UConverterToUnicodeArgs *toUArgs, 456*0e209d39SAndroid Build Coastguard Worker const char* codeUnits, 457*0e209d39SAndroid Build Coastguard Worker int32_t length, 458*0e209d39SAndroid Build Coastguard Worker UConverterCallbackReason reason, 459*0e209d39SAndroid Build Coastguard Worker UErrorCode * err); 460*0e209d39SAndroid Build Coastguard Worker 461*0e209d39SAndroid Build Coastguard Worker #endif 462*0e209d39SAndroid Build Coastguard Worker 463*0e209d39SAndroid Build Coastguard Worker #endif 464*0e209d39SAndroid Build Coastguard Worker 465*0e209d39SAndroid Build Coastguard Worker /*UCNV_ERR_H*/ 466