#include "unicode/ucnv.h"
#include "unicode/utypes.h"
Go to the source code of this file.
Compounds | |
struct | UConverterFromUnicodeArgs |
The structure for the fromUnicode callback function parameter. More... | |
struct | UConverterToUnicodeArgs |
The structure for the toUnicode callback function parameter. More... | |
Defines | |
#define | UCNV_SUB_STOP_ON_ILLEGAL "i" |
FROM_U, TO_U context options for sub callback. More... | |
#define | UCNV_SKIP_STOP_ON_ILLEGAL "i" |
FROM_U, TO_U context options for skip callback. More... | |
#define | UCNV_ESCAPE_ICU NULL |
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (UXXXX). More... | |
#define | UCNV_ESCAPE_JAVA "J" |
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\uXXXX). More... | |
#define | UCNV_ESCAPE_C "C" |
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\uXXXX \UXXXXXXXX) TO_U_CALLBACK_ESCAPE option to escape the character value accoding to C (\xXXXX). More... | |
#define | UCNV_ESCAPE_XML_DEC "D" |
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape (&DDDD;) TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Decimal escape (&DDDD;). More... | |
#define | UCNV_ESCAPE_XML_HEX "X" |
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape (&xXXXX;) TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Hex escape (&xXXXX;). More... | |
#define | UCNV_ESCAPE_UNICODE "U" |
FROM_U_CALLBACK_ESCAPE context option to escape teh code unit according to Unicode (U+XXXXX). More... | |
Enumerations | |
enum | UConverterCallbackReason { UCNV_UNASSIGNED = 0, UCNV_ILLEGAL = 1, UCNV_IRREGULAR = 2, UCNV_RESET = 3, UCNV_CLOSE = 4, UCNV_CLONE = 5 } |
The process condition code to be used with the callbacks. More... | |
Functions | |
void | UCNV_FROM_U_CALLBACK_STOP (const 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... | |
void | UCNV_TO_U_CALLBACK_STOP (const void *context, UConverterToUnicodeArgs *toUArgs, 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... | |
void | UCNV_FROM_U_CALLBACK_SKIP (const 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... | |
void | UCNV_FROM_U_CALLBACK_SUBSTITUTE (const 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... | |
void | UCNV_FROM_U_CALLBACK_ESCAPE (const 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... | |
void | UCNV_TO_U_CALLBACK_SKIP (const void *context, UConverterToUnicodeArgs *toUArgs, 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... | |
void | UCNV_TO_U_CALLBACK_SUBSTITUTE (const void *context, UConverterToUnicodeArgs *toUArgs, 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... | |
void | UCNV_TO_U_CALLBACK_ESCAPE (const void *context, UConverterToUnicodeArgs *toUArgs, 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... |
If you want to write your own, you may also find the functions from ucnv_cb.h useful when writing your own callbacks.
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. The available contexts in this header can modify the default behavior of the callback.
UErrorCode err = U_ZERO_ERROR; UConverter *myConverter = ucnv_open("ibm-949", &err); const void *oldContext; UConverterFromUCallback oldAction; if (U_SUCCESS(err)) { ucnv_setFromUCallBack(myConverter, UCNV_FROM_U_CALLBACK_STOP, NULL, &oldAction, &oldContext, &status); }
The code above tells "myConverter" to stop when it encounters an ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from Unicode -> Codepage. The behavior from Codepage to Unicode is not changed, and ucnv_setToUCallBack would need to be called in order to change that behavior too.
Here is an example with a context:
UErrorCode err = U_ZERO_ERROR; UConverter *myConverter = ucnv_open("ibm-949", &err); const void *oldContext; UConverterFromUCallback oldAction; if (U_SUCCESS(err)) { ucnv_setToUCallBack(myConverter, UCNV_TO_U_CALLBACK_SUBSTITUTE, UCNV_SUB_STOP_ON_ILLEGAL, &oldAction, &oldContext, &status); }
The code above tells "myConverter" to stop when it encounters an ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from Codepage -> Unicode. Any unmapped and legal characters will be substituted to be the default substitution character.
Definition in file ucnv_err.h.
|
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\uXXXX \UXXXXXXXX) TO_U_CALLBACK_ESCAPE option to escape the character value accoding to C (\xXXXX).
Definition at line 122 of file ucnv_err.h. |
|
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (UXXXX).
Definition at line 111 of file ucnv_err.h. |
|
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\uXXXX).
Definition at line 116 of file ucnv_err.h. |
|
FROM_U_CALLBACK_ESCAPE context option to escape teh code unit according to Unicode (U+XXXXX).
Definition at line 139 of file ucnv_err.h. |
|
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape (&DDDD;) TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Decimal escape (&DDDD;).
Definition at line 128 of file ucnv_err.h. |
|
FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape (&xXXXX;) TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Hex escape (&xXXXX;).
Definition at line 134 of file ucnv_err.h. |
|
FROM_U, TO_U context options for skip callback.
Definition at line 105 of file ucnv_err.h. |
|
FROM_U, TO_U context options for sub callback.
Definition at line 99 of file ucnv_err.h. |
|
The process condition code to be used with the callbacks. Codes which are greater than UCNV_IRREGULAR should be passed on to any chained callbacks.
Definition at line 147 of file ucnv_err.h. |
|
DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the hexadecimal representation of the illegal codepoints.
|
|
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.
|
|
DO NOT CALL THIS FUNCTION DIRECTLY! This From Unicode callback STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately.
|
|
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.
|
|
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").
|
|
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.
|
|
DO NOT CALL THIS FUNCTION DIRECTLY! This To Unicode callback STOPS at the ILLEGAL_SEQUENCE, returning the error code back to the caller immediately.
|
|
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.
|