Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ucnv_err.h File Reference

C UConverter predefined error callbacks. More...

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

Go to the source code of this file.

Compounds

struct  UConverterFromUnicodeArgs
struct  UConverterToUnicodeArgs

Defines

#define UCNV_SUB_STOP_ON_ILLEGAL   "i"
 FROM_U, TO_U options for sub and skip callbacks. More...

#define UCNV_SKIP_STOP_ON_ILLEGAL   "i"
#define UCNV_ESCAPE_ICU   NULL
 FROM_U_CALLBACK_ESCAPE options. More...

#define UCNV_ESCAPE_JAVA   "J"
#define UCNV_ESCAPE_C   "C"
#define UCNV_ESCAPE_XML_DEC   "D"
#define UCNV_ESCAPE_XML_HEX   "X"

Enumerations

enum  UConverterCallbackReason {
  UCNV_UNASSIGNED = 0, UCNV_ILLEGAL = 1, UCNV_IRREGULAR = 2, UCNV_RESET = 3,
  UCNV_CLOSE = 4
}
 The process condition code to be used with the callbacks. More...


Functions

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP ( void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately. More...

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP ( void *context, UConverterToUnicodeArgs *fromUArgs, const char* codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately. More...

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP ( void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback skips any ILLEGAL_SEQUENCE, or skips only UNASSINGED_SEQUENCE depending on the context parameter simply ignoring those characters. More...

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE ( void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or UNASSIGNED_SEQUENCE depending on context parameter, with the current substitution string for the converter. More...

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE ( void *context, UConverterFromUnicodeArgs *fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the hexadecimal representation of the illegal codepoints. More...

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP ( void *context, UConverterToUnicodeArgs *fromUArgs, const char* codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback skips any ILLEGAL_SEQUENCE, or skips only UNASSINGED_SEQUENCE depending on the context parameter simply ignoring those characters. More...

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE ( void *context, UConverterToUnicodeArgs *fromUArgs, const char* codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or UNASSIGNED_SEQUENCE depending on context parameter, with the Unicode substitution character, U+FFFD. More...

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE ( void *context, UConverterToUnicodeArgs *fromUArgs, const char* codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode * err)
 DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback will Substitute the ILLEGAL SEQUENCE with the hexadecimal representation of the illegal bytes (in the format XNN, e.g. More...


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);
  void *newContext = NULL;
  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.


Define Documentation

#define UCNV_ESCAPE_C   "C"
 

Definition at line 74 of file ucnv_err.h.

#define UCNV_ESCAPE_ICU   NULL
 

FROM_U_CALLBACK_ESCAPE options.

Definition at line 72 of file ucnv_err.h.

#define UCNV_ESCAPE_JAVA   "J"
 

Definition at line 73 of file ucnv_err.h.

#define UCNV_ESCAPE_XML_DEC   "D"
 

Definition at line 75 of file ucnv_err.h.

#define UCNV_ESCAPE_XML_HEX   "X"
 

Definition at line 76 of file ucnv_err.h.

#define UCNV_SKIP_STOP_ON_ILLEGAL   "i"
 

Definition at line 67 of file ucnv_err.h.

#define UCNV_SUB_STOP_ON_ILLEGAL   "i"
 

FROM_U, TO_U options for sub and skip callbacks.

Definition at line 66 of file ucnv_err.h.


Enumeration Type Documentation

enum UConverterCallbackReason
 

The process condition code to be used with the callbacks.

Enumeration values:
UCNV_UNASSIGNED  
UCNV_ILLEGAL  
UCNV_IRREGULAR  
UCNV_RESET  
UCNV_CLOSE  

Definition at line 81 of file ucnv_err.h.


Function Documentation

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE ( void * context,
UConverterFromUnicodeArgs * fromUArgs,
const UChar * codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the hexadecimal representation of the illegal codepoints.

Parameters:
context:   the function currently recognizes the callback options:

UCNV_ESCAPE_ICU: Substitues the ILLEGAL SEQUENCE with the hexadecimal representation in the format UXXXX, e.g. "uFFFEu00ACuC8FE"). In the Event the converter doesn't support the characters {u,%}[A-F][0-9], it will substitute the illegal sequence with the substitution characters. Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as UD84DUDC56 UCNV_ESCAPE_JAVA: Substitues the ILLEGAL SEQUENCE with the hexadecimal representation in the format \uXXXX, e.g. "\uFFFE\u00AC\uC8FE"). In the Event the converter doesn't support the characters {u,\}[A-F][0-9], it will substitute the illegal sequence with the substitution characters. Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as \uD84D\uDC56 UCNV_ESCAPE_C: Substitues the ILLEGAL SEQUENCE with the hexadecimal representation in the format \uXXXX, e.g. "\uFFFE\u00AC\uC8FE"). In the Event the converter doesn't support the characters {u,U,\}[A-F][0-9], it will substitute the illegal sequence with the substitution characters. Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as \U00023456 UCNV_ESCAPE_XML_DEC: Substitues the ILLEGAL SEQUENCE with the decimal representation in the format &DDDDDDDD, e.g. "&#65534&#172&#51454"). In the Event the converter doesn't support the characters {&,#}[0-9], it will substitute the illegal sequence with the substitution characters. Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as &#144470 and Zero padding is ignored. UCNV_ESCAPE_XML_HEX:Substitues the ILLEGAL SEQUENCE with the decimal representation in the format &xXXXX, e.g. "&xFFFE&x00AC&xC8FE"). In the Event the converter doesn't support the characters {&,#,x}[0-9], it will substitute the illegal sequence with the substitution characters. Note that codeUnit(32bit int eg: unit of a surrogate pair) is represented as &x23456
Stable:

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP ( void * context,
UConverterFromUnicodeArgs * fromUArgs,
const UChar * codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback skips any ILLEGAL_SEQUENCE, or skips only UNASSINGED_SEQUENCE depending on the context parameter simply ignoring those characters.

Parameters:
context:   the function currently recognizes the callback options: UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately. NULL: Skips any ILLEGAL_SEQUENCE

Stable:

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP ( void * context,
UConverterFromUnicodeArgs * fromUArgs,
const UChar * codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately.

Stable:

U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE ( void * context,
UConverterFromUnicodeArgs * fromUArgs,
const UChar * codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or UNASSIGNED_SEQUENCE depending on context parameter, with the current substitution string for the converter.

This is the default callback.

Parameters:
context:   the function currently recognizes the callback options: UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately. NULL: Substitutes any ILLEGAL_SEQUENCE
See also:
ucnv_setSubstChars
Stable:

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE ( void * context,
UConverterToUnicodeArgs * fromUArgs,
const char * codeUnits,
int32_t length,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback will Substitute the ILLEGAL SEQUENCE with the hexadecimal representation of the illegal bytes (in the format XNN, e.g.

"XFFX0AXC8X03").

Stable:

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP ( void * context,
UConverterToUnicodeArgs * fromUArgs,
const char * codeUnits,
int32_t length,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback skips any ILLEGAL_SEQUENCE, or skips only UNASSINGED_SEQUENCE depending on the context parameter simply ignoring those characters.

Parameters:
context:   the function currently recognizes the callback options: UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately. NULL: Skips any ILLEGAL_SEQUENCE

Stable:

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP ( void * context,
UConverterToUnicodeArgs * fromUArgs,
const char * codeUnits,
int32_t length,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately.

Stable:

U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE ( void * context,
UConverterToUnicodeArgs * fromUArgs,
const char * codeUnits,
int32_t length,
UConverterCallbackReason reason,
UErrorCode * err )
 

DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or UNASSIGNED_SEQUENCE depending on context parameter, with the Unicode substitution character, U+FFFD.

Parameters:
context:   the function currently recognizes the callback options: UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately. NULL: Substitutes any ILLEGAL_SEQUENCE
Stable:


Generated at Tue Jun 12 14:04:10 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000