|
||||
Warning, file /include/unicode/ucnv_cb.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ********************************************************************** 0005 * Copyright (C) 2000-2004, International Business Machines 0006 * Corporation and others. All Rights Reserved. 0007 ********************************************************************** 0008 * ucnv_cb.h: 0009 * External APIs for the ICU's codeset conversion library 0010 * Helena Shih 0011 * 0012 * Modification History: 0013 * 0014 * Date Name Description 0015 */ 0016 0017 /** 0018 * \file 0019 * \brief C API: UConverter functions to aid the writers of callbacks 0020 * 0021 * <h2> Callback API for UConverter </h2> 0022 * 0023 * These functions are provided here for the convenience of the callback 0024 * writer. If you are just looking for callback functions to use, please 0025 * see ucnv_err.h. DO NOT call these functions directly when you are 0026 * working with converters, unless your code has been called as a callback 0027 * via ucnv_setFromUCallback or ucnv_setToUCallback !! 0028 * 0029 * A note about error codes and overflow. Unlike other ICU functions, 0030 * these functions do not expect the error status to be U_ZERO_ERROR. 0031 * Callbacks must be much more careful about their error codes. 0032 * The error codes used here are in/out parameters, which should be passed 0033 * back in the callback's error parameter. 0034 * 0035 * For example, if you call ucnv_cbfromUWriteBytes to write data out 0036 * to the output codepage, it may return U_BUFFER_OVERFLOW_ERROR if 0037 * the data did not fit in the target. But this isn't a failing error, 0038 * in fact, ucnv_cbfromUWriteBytes may be called AGAIN with the error 0039 * status still U_BUFFER_OVERFLOW_ERROR to attempt to write further bytes, 0040 * which will also go into the internal overflow buffers. 0041 * 0042 * Concerning offsets, the 'offset' parameters here are relative to the start 0043 * of SOURCE. For example, Suppose the string "ABCD" was being converted 0044 * from Unicode into a codepage which doesn't have a mapping for 'B'. 0045 * 'A' will be written out correctly, but 0046 * The FromU Callback will be called on an unassigned character for 'B'. 0047 * At this point, this is the state of the world: 0048 * Target: A [..] [points after A] 0049 * Source: A B [C] D [points to C - B has been consumed] 0050 * 0 1 2 3 0051 * codePoint = "B" [the unassigned codepoint] 0052 * 0053 * Now, suppose a callback wants to write the substitution character '?' to 0054 * the target. It calls ucnv_cbFromUWriteBytes() to write the ?. 0055 * It should pass ZERO as the offset, because the offset as far as the 0056 * callback is concerned is relative to the SOURCE pointer [which points 0057 * before 'C'.] If the callback goes into the args and consumes 'C' also, 0058 * it would call FromUWriteBytes with an offset of 1 (and advance the source 0059 * pointer). 0060 * 0061 */ 0062 0063 #ifndef UCNV_CB_H 0064 #define UCNV_CB_H 0065 0066 #include "unicode/utypes.h" 0067 0068 #if !UCONFIG_NO_CONVERSION 0069 0070 #include "unicode/ucnv.h" 0071 #include "unicode/ucnv_err.h" 0072 0073 /** 0074 * ONLY used by FromU callback functions. 0075 * Writes out the specified byte output bytes to the target byte buffer or to converter internal buffers. 0076 * 0077 * @param args callback fromUnicode arguments 0078 * @param source source bytes to write 0079 * @param length length of bytes to write 0080 * @param offsetIndex the relative offset index from callback. 0081 * @param err error status. If <TT>U_BUFFER_OVERFLOW</TT> is returned, then U_BUFFER_OVERFLOW <STRONG>must</STRONG> 0082 * be returned to the user, because it means that not all data could be written into the target buffer, and some is 0083 * in the converter error buffer. 0084 * @see ucnv_cbFromUWriteSub 0085 * @stable ICU 2.0 0086 */ 0087 U_CAPI void U_EXPORT2 0088 ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args, 0089 const char* source, 0090 int32_t length, 0091 int32_t offsetIndex, 0092 UErrorCode * err); 0093 0094 /** 0095 * ONLY used by FromU callback functions. 0096 * This function will write out the correct substitution character sequence 0097 * to the target. 0098 * 0099 * @param args callback fromUnicode arguments 0100 * @param offsetIndex the relative offset index from the current source pointer to be used 0101 * @param err error status. If <TT>U_BUFFER_OVERFLOW</TT> is returned, then U_BUFFER_OVERFLOW <STRONG>must</STRONG> 0102 * be returned to the user, because it means that not all data could be written into the target buffer, and some is 0103 * in the converter error buffer. 0104 * @see ucnv_cbFromUWriteBytes 0105 * @stable ICU 2.0 0106 */ 0107 U_CAPI void U_EXPORT2 0108 ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args, 0109 int32_t offsetIndex, 0110 UErrorCode * err); 0111 0112 /** 0113 * ONLY used by fromU callback functions. 0114 * This function will write out the error character(s) to the target UChar buffer. 0115 * 0116 * @param args callback fromUnicode arguments 0117 * @param source pointer to pointer to first UChar to write [on exit: 1 after last UChar processed] 0118 * @param sourceLimit pointer after last UChar to write 0119 * @param offsetIndex the relative offset index from callback which will be set 0120 * @param err error status <TT>U_BUFFER_OVERFLOW</TT> 0121 * @see ucnv_cbToUWriteSub 0122 * @stable ICU 2.0 0123 */ 0124 U_CAPI void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args, 0125 const UChar** source, 0126 const UChar* sourceLimit, 0127 int32_t offsetIndex, 0128 UErrorCode * err); 0129 0130 /** 0131 * ONLY used by ToU callback functions. 0132 * This function will write out the specified characters to the target 0133 * UChar buffer. 0134 * 0135 * @param args callback toUnicode arguments 0136 * @param source source string to write 0137 * @param length the length of source string 0138 * @param offsetIndex the relative offset index which will be written. 0139 * @param err error status <TT>U_BUFFER_OVERFLOW</TT> 0140 * @see ucnv_cbToUWriteSub 0141 * @stable ICU 2.0 0142 */ 0143 U_CAPI void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args, 0144 const UChar* source, 0145 int32_t length, 0146 int32_t offsetIndex, 0147 UErrorCode * err); 0148 0149 /** 0150 * ONLY used by ToU callback functions. 0151 * This function will write out the Unicode substitution character (U+FFFD). 0152 * 0153 * @param args callback fromUnicode arguments 0154 * @param offsetIndex the relative offset index from callback. 0155 * @param err error status <TT>U_BUFFER_OVERFLOW</TT> 0156 * @see ucnv_cbToUWriteUChars 0157 * @stable ICU 2.0 0158 */ 0159 U_CAPI void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args, 0160 int32_t offsetIndex, 0161 UErrorCode * err); 0162 #endif 0163 0164 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |