1999-12-28 23:39:02 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
|
|
|
* Copyright (C) 1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ucnv_err.h:
|
|
|
|
* defines error behaviour functions called by T_UConverter_{from,to}Unicode
|
|
|
|
*
|
|
|
|
* These Functions, although public, should NEVER be called directly, they should be used as parameters to
|
|
|
|
* the T_UConverter_setMissing{Char,Unicode}Action API, to set the behaviour of a converter
|
|
|
|
* when it encounters ILLEGAL/UNMAPPED/INVALID sequences.
|
|
|
|
*
|
|
|
|
* usage example:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* UErrorCode err = U_ZERO_ERROR;
|
|
|
|
* UConverter* myConverter = T_UConverter_create("ibm-949", &err);
|
|
|
|
*
|
|
|
|
* if (U_SUCCESS(err))
|
|
|
|
* {
|
|
|
|
* T_UConverter_setMissingUnicodeAction(myConverter, (MissingUnicodeAction)UCNV_FROM_U_CALLBACK_STOP, &err);
|
|
|
|
* T_UConverter_setMissingCharAction(myConverter, (MissingCharAction)UCNV_TO_U_CALLBACK_SUBSTITUTE, &err);
|
|
|
|
* }
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* The code above tells "myConverter" to stop when it encounters a ILLEGAL/TRUNCATED/INVALID sequences when it is used to
|
|
|
|
* convert from Unicode -> Codepage.
|
|
|
|
* and to substitute with a codepage specific substitutions sequence when converting from Codepage -> Unicode
|
|
|
|
*/
|
|
|
|
|
2000-06-29 00:14:01 +00:00
|
|
|
/* This file isn't designed to be included by itself. */
|
|
|
|
#ifndef UCNV_H
|
|
|
|
# include "unicode/ucnv.h"
|
|
|
|
/* and the rest of this file will be ignored. */
|
|
|
|
#endif
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
#ifndef UCNV_ERR_H
|
|
|
|
#define UCNV_ERR_H
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2000-06-27 20:47:56 +00:00
|
|
|
/**
|
|
|
|
* The process condition code to be used with the callbacks.
|
|
|
|
* UCNV_UNASSIGNED : the code point is unassigned.
|
|
|
|
* UCNV_ILLEGAL : The code point is illegal. For example,\x81\x2E is illegal
|
|
|
|
* because \x2E is not a valid trail byte for the \x81 lead byte in SJIS.
|
|
|
|
* UCNV_IRREGULAR : The code point is not a regular sequence in the encoding.
|
|
|
|
* For example,\xC0\E1 is irregular because the same character can be represented
|
|
|
|
* as \x61.
|
|
|
|
* UCNV_RESET : Whether the conversion operation has been reset.
|
|
|
|
* UCNV_CLOSE : Whether the conversion operation has ended.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
UCNV_UNASSIGNED = 0,
|
|
|
|
UCNV_ILLEGAL = 1,
|
|
|
|
UCNV_IRREGULAR = 2,
|
|
|
|
UCNV_RESET = 3,
|
2000-06-29 03:04:28 +00:00
|
|
|
UCNV_CLOSE = 4
|
2000-06-27 20:47:56 +00:00
|
|
|
} UConverterCallbackReason;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
2000-06-27 20:47:56 +00:00
|
|
|
* The structure for the fromUnicode callback function parameter.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
uint16_t size;
|
|
|
|
UBool flush;
|
|
|
|
UConverter *converter;
|
2000-06-30 17:38:47 +00:00
|
|
|
const UChar *source;
|
2000-06-27 20:47:56 +00:00
|
|
|
const UChar *sourceLimit;
|
2000-06-30 17:38:47 +00:00
|
|
|
char *target;
|
2000-06-27 20:47:56 +00:00
|
|
|
const char *targetLimit;
|
|
|
|
int32_t *offsets; /* *offset = blah ; offset++; */
|
|
|
|
} UConverterFromUnicodeArgs;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The structure for the toUnicode callback function parameter.
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
typedef struct {
|
|
|
|
uint16_t size;
|
|
|
|
UBool flush;
|
|
|
|
UConverter *converter;
|
2000-06-30 17:38:47 +00:00
|
|
|
const char *source;
|
2000-06-27 20:47:56 +00:00
|
|
|
const char *sourceLimit;
|
2000-06-30 17:38:47 +00:00
|
|
|
UChar *target;
|
2000-06-27 20:47:56 +00:00
|
|
|
const UChar *targetLimit;
|
|
|
|
int32_t *offsets;
|
|
|
|
} UConverterToUnicodeArgs;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor STOPS at the ILLEGAL_SEQUENCE
|
|
|
|
* @stable
|
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
U_CAPI void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
|
|
|
|
void *context,
|
|
|
|
UConverterFromUnicodeArgs *fromUArgs,
|
|
|
|
const UChar* codeUnits,
|
|
|
|
int32_t length,
|
|
|
|
UChar32 codePoint,
|
|
|
|
UConverterCallbackReason reason,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode * err);
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-06-27 20:47:56 +00:00
|
|
|
/**
|
|
|
|
* Functor STOPS at the 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);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor SKIPs the ILLEGAL_SEQUENCE
|
|
|
|
* @stable
|
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
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);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor Substitute the ILLEGAL SEQUENCE with the current substitution string assiciated with _this,
|
1999-12-28 23:39:02 +00:00
|
|
|
* in the event target buffer is too small, it will store the extra info in the UConverter, and err
|
2000-08-11 19:10:10 +00:00
|
|
|
* will be set to U_BUFFER_OVERFLOW_ERROR. The next time T_UConverter_fromUnicode is called, it will
|
1999-12-28 23:39:02 +00:00
|
|
|
* store the left over data in target, before transcoding the "source Stream"
|
2000-03-22 18:31:40 +00:00
|
|
|
* @stable
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
2000-06-27 20:47:56 +00:00
|
|
|
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);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor Substitute the ILLEGAL SEQUENCE with a sequence escaped codepoints corresponding to the ILLEGAL
|
1999-12-28 23:39:02 +00:00
|
|
|
* SEQUENCE (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
|
|
|
|
* (it will behave like the above functor).
|
|
|
|
* in the event target buffer is too small, it will store the extra info in the UConverter, and err
|
2000-08-11 19:10:10 +00:00
|
|
|
* will be set to U_BUFFER_OVERFLOW_ERROR. The next time T_UConverter_fromUnicode is called, it will
|
1999-12-28 23:39:02 +00:00
|
|
|
* store the left over data in target, before transcoding the "source Stream"
|
2000-03-22 18:31:40 +00:00
|
|
|
* @stable
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
2000-06-27 20:47:56 +00:00
|
|
|
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);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor SKIPs the ILLEGAL_SEQUENCE
|
|
|
|
* @stable
|
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
|
|
|
|
void *context,
|
|
|
|
UConverterToUnicodeArgs *fromUArgs,
|
|
|
|
const char* codeUnits,
|
|
|
|
int32_t length,
|
|
|
|
UConverterCallbackReason reason,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode * err);
|
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor Substitute the ILLEGAL SEQUENCE with the current substitution string assiciated with _this,
|
1999-12-28 23:39:02 +00:00
|
|
|
* in the event target buffer is too small, it will store the extra info in the UConverter, and err
|
2000-08-11 19:10:10 +00:00
|
|
|
* will be set to U_BUFFER_OVERFLOW_ERROR. The next time T_UConverter_fromUnicode is called, it will
|
1999-12-28 23:39:02 +00:00
|
|
|
* store the left over data in target, before transcoding the "source Stream"
|
2000-03-22 18:31:40 +00:00
|
|
|
* @stable
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
|
|
|
|
void *context,
|
|
|
|
UConverterToUnicodeArgs *fromUArgs,
|
|
|
|
const char* codeUnits,
|
|
|
|
int32_t length,
|
|
|
|
UConverterCallbackReason reason,
|
|
|
|
UErrorCode * err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Functor Substitute the ILLEGAL SEQUENCE with a sequence escaped codepoints corresponding to the
|
1999-12-28 23:39:02 +00:00
|
|
|
* ILLEGAL SEQUENCE (format %XNN, e.g. "%XFF%X0A%XC8%X03").
|
|
|
|
* in the event target buffer is too small, it will store the extra info in the UConverter, and err
|
2000-08-11 19:10:10 +00:00
|
|
|
* will be set to U_BUFFER_OVERFLOW_ERROR. The next time T_UConverter_fromUnicode is called, it will
|
1999-12-28 23:39:02 +00:00
|
|
|
* store the left over data in target, before transcoding the "source Stream"
|
2000-03-22 18:31:40 +00:00
|
|
|
* @stable
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
2000-06-27 20:47:56 +00:00
|
|
|
U_CAPI void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (
|
|
|
|
void *context,
|
|
|
|
UConverterToUnicodeArgs *fromUArgs,
|
|
|
|
const char* codeUnits,
|
|
|
|
int32_t length,
|
|
|
|
UConverterCallbackReason reason,
|
|
|
|
UErrorCode * err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
#endif/*UCNV_ERR_H*/
|