source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/util/Transcoders/Iconv400/iconv_cnv.hpp @ 2674

Revision 2674, 13.2 KB checked in by mattausch, 16 years ago (diff)
Line 
1#if (__OS400_TGTVRM__>=510)                               /* @01a */
2    #pragma datamodel(P128)                               /* @01a */
3#endif                                                    /* @01a */
4
5/*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements.  See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22/*
23 * $Id: iconv_cnv.hpp 568078 2007-08-21 11:43:25Z amassari $
24 */
25
26#ifndef UCNV_H
27#define UCNV_H
28
29#include "utypes.h"
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33/**
34 * Creates a UConverter object with the names specified as a C string.
35 * The actual name will be resolved with the alias file.
36 * if <TT>NULL</TT> is passed for the converter name, it will create one with the
37 * getDefaultName return value.
38 * @param converterName : name of the uconv table
39 * @param err outgoing error status <TT>MEMORY_ALLOCATION_ERROR, TABLE_NOT_FOUND</TT>
40 * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
41 * @see ucnv_openU
42 * @see ucnv_openCCSID
43 * @see ucnv_close
44 */
45
46U_CAPI
47UConverter* U_EXPORT2 ucnv_open   (const char *converterName,
48                                   UErrorCode * err);
49
50
51/**
52 * Creates a Unicode converter with the names specified as unicode string. The name should be limited to
53 * the ASCII-7 alphanumerics range. The actual name will be resolved with the alias file.
54 * if <TT>NULL</TT> is passed for the converter name, it will create one with the
55 * getDefaultName return value.
56 * @param converterName : name of the uconv table in a zero terminated Unicode string
57 * @param err outgoing error status <TT>MEMORY_ALLOCATION_ERROR, TABLE_NOT_FOUND</TT>
58 * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
59 * @see ucnv_open
60 * @see ucnv_openCCSID
61 * @see ucnv_close
62 */
63U_CAPI UConverter* U_EXPORT2 ucnv_openU (const UChar * name,
64                                       UErrorCode * err);
65
66
67
68/**
69 * Creates a UConverter object using a CCSID number.
70 * @param codepage : codepage # of the uconv table
71 * @param platform : codepage's platform (now only <TT>IBM</TT> supported)
72 * @param err error status <TT>MEMORY_ALLOCATION_ERROR, TABLE_NOT_FOUND</TT>
73 * @return the created Unicode converter object, or <TT>NULL</TT> if and error occured
74 * @see ucnv_open
75 * @see ucnv_openU
76 * @see ucnv_close
77 */
78
79
80U_CAPI void  U_EXPORT2 ucnv_close (UConverter * converter);
81
82
83
84
85/**
86 * Returns the maximum length of bytes used by a character. This varies between 1 and 4
87 * @param converter the Unicode converter
88 * @return the maximum number of bytes allowed by this particular converter
89 * @see ucnv_getMinCharSize
90 */
91U_CAPI int8_t U_EXPORT2
92    ucnv_getMaxCharSize (const UConverter * converter);
93
94
95/**
96 * Returns the minimum byte length for characters in this codepage. This is either
97 * 1 or 2 for all supported codepages.
98 * @param converter the Unicode converter
99 * @return the minimum number of bytes allowed by this particular converter
100 * @see ucnv_getMaxCharSize
101 */
102U_CAPI int8_t U_EXPORT2
103    ucnv_getMinCharSize (const UConverter * converter);
104
105
106/**
107 * Transcodes an array of unicode characters to an array of codepage characters.
108 * The source pointer is an I/O parameter, it starts out pointing where the function is
109 * to begin transcoding, and ends up pointing after the first sequence of the bytes
110 * that it encounters that are semantically invalid.
111 * if ucnv_setToUCallBack is called with an action other than <TT>STOP</TT>
112 * before a call is made to this API, <TT>consumed</TT> and <TT>source</TT> should point to the same place
113 * (unless <TT>target</TT> ends with an imcomplete sequence of bytes and <TT>flush</TT> is <TT>FALSE</TT>).
114 * the <TT>target</TT> buffer buffer needs to be a least the size of the maximum # of bytes per characters
115 * allowed by the target codepage.
116 * @param converter the Unicode converter
117 * @param converter the Unicode converter
118 * @param target : I/O parameter. Input : Points to the beginning of the buffer to copy
119 *  codepage characters to. Output : points to after the last codepage character copied
120 *  to <TT>target</TT>.
121 * @param targetLimit the pointer to the end of the <TT>target</TT> array
122 * @param source the source Unicode character array
123 * @param sourceLimit the pointer to the end of the source array
124 * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
125 * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
126 * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
127 * For output data carried across calls -1 will be placed for offsets.
128 * @param flush <TT>TRUE</TT> if the buffer is the last buffer of the conversion interation
129 * and the conversion will finish with this call, FALSE otherwise.
130 * @param err the error status.  <TT>ILLEGAL_ARGUMENT_ERROR</TT> will be returned if the
131 * converter is <TT>NULL</TT>.
132 * @see ucnv_fromUChars
133 * @see ucnv_convert
134 * @see ucnv_getMinCharSize
135 * @see ucnv_setToUCallBack
136 */
137
138U_CAPI
139  void U_EXPORT2 ucnv_fromUnicode (UConverter * converter,
140                         char **target,
141                         const char *targetLimit,
142                         const UChar ** source,
143                         const UChar * sourceLimit,
144                         int32_t* offsets,
145                         int flush,
146                         UErrorCode * err);
147
148
149/**
150 * Converts an array of codepage characters into an array of unicode characters.
151 * The source pointer is an I/O parameter, it starts out pointing at the place
152 * to begin translating, and ends up pointing after the first sequence of the bytes
153 * that it encounters that are semantically invalid.
154 * if ucnv_setFromUCallBack is called with an action other than STOP
155 * before a call is made to this API, consumed and source should point to the same place
156 * (unless target ends with an imcomplete sequence of bytes and flush is FALSE).
157 * @param converter the Unicode converter
158 * @param target : I/O parameter. Input : Points to the beginning of the buffer to copy
159 *  Unicode characters to. Output : points to after the last UChar copied to target.
160 * @param targetLimit the pointer to the end of the target array
161 * @param source the source codepage character array
162 * @param sourceLimit the pointer to the end of the source array
163 * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
164 * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
165 * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
166 * For output data carried across calls -1 will be placed for offsets.
167 * @param flush TRUE if the buffer is the last buffer and the conversion will finish
168 * in this call, FALSE otherwise.
169 * @param err the error code status  <TT>ILLEGAL_ARGUMENT_ERROR</TT> will be returned if the
170 * converter is <TT>NULL</TT>, or if <TT>targetLimit</TT> and <TT>sourceLimit</TT> are misaligned.
171 * @see ucnv_toUChars
172 * @see ucnv_getNextUChar
173 * @see ucnv_convert
174 * @see ucnv_setFromUCallBack
175 */
176
177U_CAPI
178  void U_EXPORT2 ucnv_toUnicode (UConverter * converter,
179                       UChar ** target,
180                       const UChar * targetLimit,
181                       const char **source,
182                       const char *sourceLimit,
183                       int32_t* offsets,
184                       int flush,
185                       UErrorCode * err);
186
187
188/**
189 * Transcodes the source Unicode string to the target string in a codepage encoding
190 * with the specified Unicode converter.  For example, if a Unicode to/from JIS
191 * converter is specified, the source string in Unicode will be transcoded to JIS
192 * encoding.  The result will be stored in JIS encoding.
193 * if any problems during conversion are encountered it will SUBSTITUTE with the default (initial)
194 * substitute characters.
195 * This function is a more convenient but less efficient version of \Ref{ucnv_fromUnicode}.
196 * @param converter the Unicode converter
197 * @param source the <TT>source</TT> Unicode string (zero Terminated)
198 * @param target the <TT>target</TT> string in codepage encoding (<STRONG>not zero-terminated</STRONG> because some
199 * codepage do not use '\0' as a string terminator
200 * @param targetCapacity Input the number of bytes available in the <TT>target</TT> buffer
201 * @param err the error status code.
202 * <TT>INDEX_OUTOFBOUNDS_ERROR</TT> will be returned if the
203 * the # of bytes provided are not enough for transcoding.
204 * <TT>ILLEGAL_ARGUMENT_ERROR</TT> is returned if the converter is <TT>NULL</TT> or the source or target string is empty.
205 * <TT>BUFFER_OVERFLOW_ERROR</TT> when <TT>targetSize</TT> turns out to be bigger than <TT>targetCapacity</TT>
206 * @return number of bytes needed in target, regardless of <TT>targetCapacity</TT>
207 * @see ucnv_fromUnicode
208 * @see ucnv_convert
209 */
210U_CAPI
211  int32_t U_EXPORT2 ucnv_fromUChars (const UConverter * converter,
212                           char *target,
213                           int32_t targetCapacity,
214                           const UChar * source,
215                           UErrorCode * err);
216
217
218
219
220
221/**
222 * Transcode the source string in codepage encoding to the target string in
223 * Unicode encoding.  For example, if a Unicode to/from JIS
224 * converter is specified, the source string in JIS encoding will be transcoded
225 * to Unicode and placed into a provided target buffer.
226 * if any problems during conversion are encountered it will SUBSTITUTE with the Unicode REPLACEMENT char
227 * We recomment, the size of the target buffer needs to be at least as long as the maximum # of bytes per char
228 * in this character set.
229 * A zero-terminator will be placed at the end of the target buffer
230 * This function is a more convenient but less efficient version of \Ref{ucnv_toUnicode}.
231 * @param converter the Unicode converter
232 * @param source the source string in codepage encoding
233 * @param target the target string in Unicode encoding
234 * @param targetCapacity capacity of the target buffer
235 * @param sourceSize : Number of bytes in <TT>source</TT> to be transcoded
236 * @param err the error status code
237 * <TT>MEMORY_ALLOCATION_ERROR</TT> will be returned if the
238 * the internal process buffer cannot be allocated for transcoding.
239 * <TT>ILLEGAL_ARGUMENT_ERROR</TT> is returned if the converter is <TT>NULL</TT> or
240 * if the source or target string is empty.
241 * <TT>BUFFER_OVERFLOW_ERROR</TT> when the input buffer is prematurely exhausted and targetSize non-<TT>NULL</TT>.
242 * @return the number of UChar needed in target (including the zero terminator)
243 * @see ucnv_getNextUChar
244 * @see ucnv_toUnicode
245 * @see ucnv_convert
246 */
247U_CAPI
248  int32_t U_EXPORT2 ucnv_toUChars (const UConverter * converter,
249                         UChar * target,
250                         int32_t targetCapacity,
251                         const char *source,
252                         int32_t sourceSize,
253                         UErrorCode * err);
254
255/********************************
256 * Will convert a codepage buffer one character at a time.
257 * This function was written to be efficient when transcoding small amounts of data at a time.
258 * In that case it will be more efficient than \Ref{ucnv_toUnicode}.
259 * When converting large buffers use \Ref{ucnv_toUnicode}.
260 *@param converter an open UConverter
261 *@param source the address of a pointer to the codepage buffer, will be updated to point after
262 *the bytes consumed in the conversion call.
263 *@param points to the end of the input buffer
264 *@param err fills in error status (see ucnv_toUnicode)
265 *@return a UChar resulting from the partial conversion of source
266 *@see ucnv_toUnicode
267 *@see ucnv_toUChars
268 *@see ucnv_convert
269 */
270U_CAPI
271  UChar U_EXPORT2 ucnv_getNextUChar (UConverter * converter,
272                           const char **source,
273                           const char *sourceLimit,
274                           UErrorCode * err);
275
276
277/**************************
278* Will convert a sequence of bytes from one codepage to another.
279* This is <STRONG>NOT AN EFFICIENT</STRONG> way to transcode.
280* use \Ref{ucnv_toUnicode} and \Ref{ucnv_fromUnicode} for efficiency
281* @param toConverterName: The name of the converter that will be used to encode the output buffer
282* @param fromConverterName: The name of the converter that will be used to decode the input buffer
283* @param target: Pointer to the output buffer to write to
284* @param targetCapacity: on input contains the capacity of target
285* @param source: Pointer to the input buffer
286* @param sourceLength: on input contains the capacity of source
287* @param err: fills in an error status
288* @return  will be filled in with the number of bytes needed in target
289* @see ucnv_fromUnicode
290* @see ucnv_toUnicode
291* @see ucnv_fromUChars
292* @see ucnv_toUChars
293* @see ucnv_getNextUChar
294*/
295U_CAPI
296  int32_t U_EXPORT2 ucnv_convert (const char *toConverterName,
297                        const char *fromConverterName,
298                        char *target,
299                        int32_t targetCapacity,
300                        const char *source,
301                        int32_t sourceLength,
302                        UErrorCode * err);
303
304XERCES_CPP_NAMESPACE_END
305
306#endif
307
308#if (__OS400_TGTVRM__>=510)                                /* @01a */ 
309     #pragma datamodel(pop)                                /* @01a */
310#endif                                                     /* @01a */
311
Note: See TracBrowser for help on using the repository browser.