Logo Search packages:      
Sourcecode: icu version File versions

ucnv_err.h File Reference


Detailed Description

C UConverter predefined error callbacks.

Error Behaviour Fnctions

Defines some error behaviour functions called by ucnv_{from,to}Unicode These are provided as part of ICU and many are stable, but they can also be considered only as an example of what can be done with callbacks. You may of course write your own.

These Functions, although public, should NEVER be called directly, they should be used as parameters to the ucnv_setFromUCallback and ucnv_setToUCallback functions, to set the behaviour of a converter when it encounters ILLEGAL/UNMAPPED/INVALID sequences.

usage example: 'STOP' doesn't need any context, but newContext could be set to something other than 'NULL' if needed.

    UErrorCode err = U_ZERO_ERROR;
    UConverter* myConverter = ucnv_open("ibm-949", &err);
  const void *newContext = NULL;
  const void *oldContext;
  UConverterFromUCallback oldAction;


    if (U_SUCCESS(err))
    {
  ucnv_setFromUCallBack(myConverter,
                       UCNV_FROM_U_CALLBACK_STOP,
                       newContext,
                       &oldAction,
                       &oldContext,
                      &status);
    }

The code above tells "myConverter" to stop when it encounters a ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from Unicode -> Codepage. The behavior from Codepage to Unicode is not changed.

Definition in file ucnv_err.h.

#include "unicode/ucnv.h"
#include "unicode/utypes.h"

Go to the source code of this file.

Classes

struct  UConverterFromUnicodeArgs
struct  UConverterToUnicodeArgs

Defines

#define UCNV_ESCAPE_C   "C"
#define UCNV_ESCAPE_ICU   NULL
#define UCNV_ESCAPE_JAVA   "J"
#define UCNV_ESCAPE_UNICODE   "U"
#define UCNV_ESCAPE_XML_DEC   "D"
#define UCNV_ESCAPE_XML_HEX   "X"
#define UCNV_SKIP_STOP_ON_ILLEGAL   "i"
#define UCNV_SUB_STOP_ON_ILLEGAL   "i"

Enumerations

enum  UConverterCallbackReason {
  UCNV_UNASSIGNED = 0, UCNV_ILLEGAL = 1, UCNV_IRREGULAR = 2, UCNV_RESET = 3,
  UCNV_CLOSE = 4
}

Functions

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (const void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar *codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (const void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar *codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (const void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar *codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (const void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar *codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (const void *context, UConverterToUnicodeArgs *fromUArgs, const char *codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (const void *context, UConverterToUnicodeArgs *fromUArgs, const char *codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (const void *context, UConverterToUnicodeArgs *fromUArgs, const char *codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode *err)
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (const void *context, UConverterToUnicodeArgs *fromUArgs, const char *codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode *err)


Generated by  Doxygen 1.6.0   Back to index