~ubuntu-branches/ubuntu/gutsy/icu/gutsy

« back to all changes in this revision

Viewing changes to source/common/unicode/ucnv.h

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2005-11-19 11:29:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20051119112931-vcizkrp10tli4enw
Tags: 3.4-3
Explicitly build with g++ 3.4.  The current ICU fails its test suite
with 4.0 but not with 3.4.  Future versions should work properly with
4.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
**********************************************************************
3
 
*   Copyright (C) 1999-2001, International Business Machines
4
 
*   Corporation and others.  All Rights Reserved.
5
 
**********************************************************************
6
 
 *  ucnv.h:
7
 
 *  External APIs for the ICU's codeset conversion library
8
 
 *  Bertrand A. Damiba
9
 
 *
10
 
 * Modification History:
11
 
 *
12
 
 *   Date        Name        Description
13
 
 *   04/04/99    helena      Fixed internal header inclusion.
14
 
 *   05/11/00    helena      Added setFallback and usesFallback APIs.
15
 
 *   06/29/2000  helena      Major rewrite of the callback APIs.
16
 
 *   12/07/2000  srl         Update of documentation
17
 
 */
18
 
 
19
 
/**
20
 
 * \file
21
 
 * \brief C API: Character conversion 
22
 
 *
23
 
 * <h2>Character Conversion C API </h2>
24
 
 *
25
 
 */
26
 
 
27
 
#ifndef UCNV_H
28
 
#define UCNV_H
29
 
 
30
 
/** Forward declaring the UConverter structure. @stable */
31
 
struct UConverter;
32
 
 
33
 
/** @stable */
34
 
typedef struct UConverter UConverter;
35
 
 
36
 
#include "unicode/utypes.h"
37
 
#include "unicode/ucnv_err.h"
38
 
 
39
 
U_CDECL_BEGIN
40
 
 
41
 
/* maximum length of the converter names */
42
 
#define UCNV_MAX_CONVERTER_NAME_LENGTH 60
43
 
#define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
44
 
 
45
 
#define  UCNV_SI 0x0F           /*Shift in for EBDCDIC_STATEFUL and iso2022 states */
46
 
#define  UCNV_SO 0x0E           /*Shift out for EBDCDIC_STATEFUL and iso2022 states */
47
 
 
48
 
/**
49
 
 * Enum for specifying basic types of converters
50
 
 * @see ucnv_getType
51
 
 * @stable
52
 
 */
53
 
typedef enum {
54
 
    UCNV_UNSUPPORTED_CONVERTER = -1,
55
 
    UCNV_SBCS = 0,
56
 
    UCNV_DBCS = 1,
57
 
    UCNV_MBCS = 2,
58
 
    UCNV_LATIN_1 = 3,
59
 
    UCNV_UTF8 = 4,
60
 
    UCNV_UTF16_BigEndian = 5,
61
 
    UCNV_UTF16_LittleEndian = 6,
62
 
    UCNV_UTF32_BigEndian = 7,
63
 
    UCNV_UTF32_LittleEndian = 8,
64
 
    UCNV_EBCDIC_STATEFUL = 9,
65
 
    UCNV_ISO_2022 = 10,
66
 
 
67
 
    UCNV_LMBCS_1 = 11,
68
 
    UCNV_LMBCS_2, 
69
 
    UCNV_LMBCS_3,
70
 
    UCNV_LMBCS_4,
71
 
    UCNV_LMBCS_5,
72
 
    UCNV_LMBCS_6,
73
 
    UCNV_LMBCS_8,
74
 
    UCNV_LMBCS_11,
75
 
    UCNV_LMBCS_16,
76
 
    UCNV_LMBCS_17,
77
 
    UCNV_LMBCS_18,
78
 
    UCNV_LMBCS_19,
79
 
    UCNV_LMBCS_LAST = UCNV_LMBCS_19,
80
 
    UCNV_HZ,
81
 
    UCNV_SCSU,
82
 
    UCNV_ISCII,
83
 
    UCNV_US_ASCII,
84
 
    UCNV_UTF7,
85
 
 
86
 
    /* Number of converter types for which we have conversion routines. */
87
 
    UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
88
 
   
89
 
} UConverterType;
90
 
 
91
 
/**
92
 
 * Enum for specifying which platform a converter ID refers to.
93
 
 * The use of platform/CCSID is not recommended. See ucnv_openCCSID().
94
 
 *
95
 
 * @see ucnv_getPlatform
96
 
 * @see ucnv_openCCSID
97
 
 * @see ucnv_getCCSID
98
 
 * @stable
99
 
 */
100
 
typedef enum {
101
 
    UCNV_UNKNOWN = -1,
102
 
    UCNV_IBM = 0
103
 
} UConverterPlatform;
104
 
 
105
 
/**
106
 
 * Function pointer for error callback in the codepage to unicode direction.
107
 
 * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason).
108
 
 * @param context Pointer to the callback's private data
109
 
 * @param args Information about the conversion in progress
110
 
 * @param codePoints Points to 'length' bytes of the concerned codepage sequence
111
 
 * @param length Size (in bytes) of the concerned codepage sequence
112
 
 * @param reason Defines the reason the callback was invoked
113
 
 * @see ucnv_setToUCallBack
114
 
 * @see UConverterToUnicodeArgs
115
 
 * @stable
116
 
 */
117
 
typedef void (U_EXPORT2 *UConverterToUCallback) (
118
 
                  const void* context,
119
 
                  UConverterToUnicodeArgs *args,
120
 
                  const char *codePoints,
121
 
                  int32_t length,
122
 
                  UConverterCallbackReason reason,
123
 
                  UErrorCode *);
124
 
 
125
 
/**
126
 
 * Function pointer for error callback in the unicode to codepage direction.
127
 
 * Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason).
128
 
 * @param context Pointer to the callback's private data
129
 
 * @param args Information about the conversion in progress
130
 
 * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
131
 
 * @param length Size (in bytes) of the concerned codepage sequence
132
 
 * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
133
 
 * @param reason Defines the reason the callback was invoked
134
 
 * @see ucnv_setFromUCallBack
135
 
 * @stable
136
 
 */
137
 
typedef void (U_EXPORT2 *UConverterFromUCallback) (
138
 
                    const void* context,
139
 
                    UConverterFromUnicodeArgs *args,
140
 
                    const UChar* codeUnits,
141
 
                    int32_t length,
142
 
                    UChar32 codePoint,
143
 
                    UConverterCallbackReason reason,
144
 
                    UErrorCode *);
145
 
 
146
 
U_CDECL_END
147
 
 
148
 
/**
149
 
 * Character that separates converter names from options and options from each other.
150
 
 * @see ucnv_open
151
 
 * @stable
152
 
 */
153
 
#define UCNV_OPTION_SEP_CHAR ','
154
 
 
155
 
/**
156
 
 * String version of UCNV_OPTION_SEP_CHAR. 
157
 
 * @see ucnv_open
158
 
 * @stable
159
 
 */
160
 
#define UCNV_OPTION_SEP_STRING ","
161
 
 
162
 
/**
163
 
 * Character that separates a converter option from its value.
164
 
 * @see ucnv_open
165
 
 * @stable
166
 
 */
167
 
#define UCNV_VALUE_SEP_CHAR '='
168
 
 
169
 
/**
170
 
 * String version of UCNV_VALUE_SEP_CHAR. 
171
 
 * @see ucnv_open
172
 
 * @stable
173
 
 */
174
 
#define UCNV_VALUE_SEP_STRING "="
175
 
 
176
 
/**
177
 
 * Converter option for specifying a locale.
178
 
 * @see ucnv_open
179
 
 * @stable
180
 
 */
181
 
#define UCNV_LOCALE_OPTION_STRING ",locale="
182
 
 
183
 
/**
184
 
 * Do a fuzzy compare of a two converter/alias names.  The comparison
185
 
 * is case-insensitive.  It also ignores the characters '-', '_', and
186
 
 * ' ' (dash, underscore, and space).  Thus the strings "UTF-8",
187
 
 * "utf_8", and "Utf 8" are exactly equivalent.
188
 
 * 
189
 
 * @param name1 a converter name or alias, zero-terminated
190
 
 * @param name2 a converter name or alias, zero-terminated
191
 
 * @return 0 if the names match, or a negative value if the name1
192
 
 * lexically precedes name2, or a positive value if the name1
193
 
 * lexically follows name2.
194
 
 * @stable
195
 
 */
196
 
U_CAPI int U_EXPORT2
197
 
ucnv_compareNames(const char *name1, const char *name2);
198
 
 
199
 
 
200
 
/**
201
 
 * Creates a UConverter object with the names specified as a C string.
202
 
 * The actual name will be resolved with the alias file
203
 
 * using a case-insensitive string comparison that ignores
204
 
 * the delimiters '-', '_', and ' ' (dash, underscore, and space).
205
 
 * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent.
206
 
 * If <code>NULL</code> is passed for the converter name, it will create one with the
207
 
 * getDefaultName return value.
208
 
 *
209
 
 * <p>A converter name for ICU 1.5 and above may contain options
210
 
 * like a locale specification to control the specific behavior of
211
 
 * the newly instantiated converter.
212
 
 * The meaning of the options depends on the particular converter.
213
 
 * If an option is not defined for or recognized by a given converter, then it is ignored.</p>
214
 
 *
215
 
 * <p>Options are appended to the converter name string, with a
216
 
 * <code>UCNV_OPTION_SEP_CHAR</code> between the name and the first option and
217
 
 * also between adjacent options.</p>
218
 
 *
219
 
 * @param converterName : name of the uconv table, may have options appended
220
 
 * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
221
 
 * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
222
 
 * @see ucnv_openU
223
 
 * @see ucnv_openCCSID
224
 
 * @see ucnv_close
225
 
 * @stable
226
 
 */
227
 
U_CAPI UConverter* U_EXPORT2 
228
 
ucnv_open   (const char *converterName, UErrorCode * err);
229
 
 
230
 
 
231
 
/**
232
 
 * Creates a Unicode converter with the names specified as unicode string. 
233
 
 * The name should be limited to the ASCII-7 alphanumerics range.
234
 
 * The actual name will be resolved with the alias file
235
 
 * using a case-insensitive string comparison that ignores
236
 
 * the delimiters '-', '_', and ' ' (dash, underscore, and space).
237
 
 * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent.
238
 
 * If <TT>NULL</TT> is passed for the converter name, it will create 
239
 
 * one with the ucnv_getDefaultName() return value.
240
 
 * @param converterName : name of the uconv table in a zero terminated 
241
 
 *        Unicode string
242
 
 * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, 
243
 
 *        U_FILE_ACCESS_ERROR</TT>
244
 
 * @return the created Unicode converter object, or <TT>NULL</TT> if an 
245
 
 *        error occured
246
 
 * @see ucnv_open
247
 
 * @see ucnv_openCCSID
248
 
 * @see ucnv_close
249
 
 * @see ucnv_getDefaultName
250
 
 * @stable
251
 
 */
252
 
U_CAPI UConverter* U_EXPORT2 
253
 
ucnv_openU (const UChar * name,
254
 
            UErrorCode * err);
255
 
 
256
 
/**
257
 
 * Creates a UConverter object from a CCSID number and platform pair.
258
 
 * Note that the usefulness of this function is limited to platforms with numeric
259
 
 * encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for
260
 
 * encodings.
261
 
 *
262
 
 * In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related.
263
 
 * For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and
264
 
 * for some Unicode conversion tables there are multiple CCSIDs.
265
 
 * Some "alternate" Unicode conversion tables are provided by the
266
 
 * IBM CDRA conversion table registry.
267
 
 * The most prominent example of a systematic modification of conversion tables that is
268
 
 * not provided in the form of conversion table files in the repository is
269
 
 * that S/390 Unix System Services swaps the codes for Line Feed and New Line in all
270
 
 * EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well.
271
 
 *
272
 
 * Only IBM default conversion tables are accessible with ucnv_openCCSID().
273
 
 * ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated
274
 
 * with that CCSID.
275
 
 *
276
 
 * Currently, the only "platform" supported in the ICU converter API is UCNV_IBM.
277
 
 *
278
 
 * In summary, the use of CCSIDs and the associated API functions is not recommended.
279
 
 *
280
 
 * In order to open a converter with the default IBM CDRA Unicode conversion table,
281
 
 * you can use this function or use the prefix "ibm-":
282
 
 * \code
283
 
 *     char name[20];
284
 
 *     sprintf(name, "ibm-%hu", ccsid);
285
 
 *     cnv=ucnv_open(name, &errorCode);
286
 
 * \endcode
287
 
 *
288
 
 * In order to open a converter with the IBM S/390 Unix System Services variant of a Unicode/EBCDIC conversion table,
289
 
 * you can use the prefix "ibm-" together with the suffix "-s390":
290
 
 * \code
291
 
 *     char name[20];
292
 
 *     sprintf(name, "ibm-%hu-s390", ccsid);
293
 
 *     cnv=ucnv_open(name, &errorCode);
294
 
 * \endcode
295
 
 *
296
 
 * In order to open a converter from a Microsoft codepage number, use the prefix "cp":
297
 
 * \code
298
 
 *     char name[20];
299
 
 *     sprintf(name, "cp%hu", codepageID);
300
 
 *     cnv=ucnv_open(name, &errorCode);
301
 
 * \endcode
302
 
 *
303
 
 * @param codepage codepage number to create
304
 
 * @param platform the platform in which the codepage number exists
305
 
 * @param err error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
306
 
 * @return the created Unicode converter object, or <TT>NULL</TT> if an error
307
 
 *   occured.
308
 
 * @see ucnv_open
309
 
 * @see ucnv_openU
310
 
 * @see ucnv_close
311
 
 * @see ucnv_getCCSID
312
 
 * @see ucnv_getPlatform
313
 
 * @see UConverterPlatform
314
 
 * @stable
315
 
 */
316
 
U_CAPI UConverter* U_EXPORT2
317
 
ucnv_openCCSID (int32_t codepage,
318
 
                UConverterPlatform platform,
319
 
                UErrorCode * err);
320
 
 
321
 
/**
322
 
 * Thread safe cloning operation
323
 
 * @param cnv converter to be cloned
324
 
 * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. 
325
 
 *  If buffer is not large enough, new memory will be allocated.
326
 
 *  Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
327
 
 * @param pBufferSize pointer to size of allocated space. 
328
 
 *  If *pBufferSize == 0, a sufficient size for use in cloning will 
329
 
 *  be returned ('pre-flighting')
330
 
 *  If *pBufferSize is not enough for a stack-based safe clone, 
331
 
 *  new memory will be allocated.
332
 
 * @param status to indicate whether the operation went on smoothly or there were errors
333
 
 *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary.
334
 
 * @return pointer to the new clone
335
 
 * @draft ICU 1.8
336
 
 */
337
 
U_CAPI UConverter * U_EXPORT2 
338
 
ucnv_safeClone(const UConverter *cnv, 
339
 
               void             *stackBuffer,
340
 
               int32_t          *pBufferSize, 
341
 
               UErrorCode       *status);
342
 
 
343
 
/** @draft ICU 1.8 */
344
 
#define U_CNV_SAFECLONE_BUFFERSIZE 512
345
 
 
346
 
/**
347
 
 * Deletes the unicode converter and releases resources associated
348
 
 * with just this instance.
349
 
 * Does not free up shared converter tables.
350
 
 *
351
 
 * @param converter the converter object to be deleted
352
 
 * @see ucnv_open
353
 
 * @see ucnv_openU
354
 
 * @see ucnv_openCCSID
355
 
 * @stable
356
 
 */
357
 
U_CAPI void  U_EXPORT2
358
 
ucnv_close (UConverter * converter);
359
 
 
360
 
/**
361
 
 * Fills in the output parameter, subChars, with the substitution characters
362
 
 * as multiple bytes.
363
 
 *
364
 
 * @param converter the Unicode converter
365
 
 * @param subChars the subsitution characters
366
 
 * @param len on input the capacity of subChars, on output the number 
367
 
 * of bytes copied to it
368
 
 * @param  err the outgoing error status code.
369
 
 * If the substitution character array is too small, an
370
 
 * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
371
 
 * @see ucnv_setSubstChars
372
 
 * @stable
373
 
 */
374
 
U_CAPI void U_EXPORT2
375
 
ucnv_getSubstChars (const UConverter * converter,
376
 
                    char *subChars,
377
 
                    int8_t * len,
378
 
                    UErrorCode * err);
379
 
 
380
 
/**
381
 
 * Sets the substitution chars when converting from unicode to a codepage. The
382
 
 * substitution is specified as a string of 1-4 bytes, and may contain
383
 
 *  <TT>NULL</TT> byte.
384
 
 * @param converter the Unicode converter
385
 
 * @param subChars the substitution character byte sequence we want set
386
 
 * @param len the number of bytes in subChars
387
 
 * @param err the error status code.  <TT>U_INDEX_OUTOFBOUNDS_ERROR </TT> if
388
 
 * len is bigger than the maximum number of bytes allowed in subchars
389
 
 * @see ucnv_getSubstChars
390
 
 * @stable
391
 
 */
392
 
U_CAPI void U_EXPORT2
393
 
ucnv_setSubstChars (UConverter * converter,
394
 
                    const char *subChars,
395
 
                    int8_t len,
396
 
                    UErrorCode * err);
397
 
 
398
 
/**
399
 
 * Fills in the output parameter, errBytes, with the error characters from the
400
 
 * last failing conversion.
401
 
 *
402
 
 * @param converter the Unicode converter
403
 
 * @param errBytes the codepage bytes which were in error
404
 
 * @param len on input the capacity of errBytes, on output the number of
405
 
 *  bytes which were copied to it
406
 
 * @param err the error status code.
407
 
 * If the substitution character array is too small, an
408
 
 * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
409
 
 * @stable
410
 
 */
411
 
U_CAPI void U_EXPORT2
412
 
ucnv_getInvalidChars (const UConverter * converter,
413
 
                      char *errBytes,
414
 
                      int8_t * len,
415
 
                      UErrorCode * err);
416
 
 
417
 
/**
418
 
 * Fills in the output parameter, errChars, with the error characters from the
419
 
 * last failing conversion.
420
 
 *
421
 
 * @param converter the Unicode converter
422
 
 * @param errUChars the UChars which were in error
423
 
 * @param len on input the capacity of errUChars, on output the number of 
424
 
 *  UChars which were copied to it
425
 
 * @param err the error status code.
426
 
 * If the substitution character array is too small, an
427
 
 * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
428
 
 * @stable
429
 
 */
430
 
U_CAPI void U_EXPORT2
431
 
ucnv_getInvalidUChars (const UConverter * converter,
432
 
                       UChar *errUChars,
433
 
                       int8_t * len,
434
 
                       UErrorCode * err);
435
 
 
436
 
/**
437
 
 * Resets the state of a converter to the default state. This is used
438
 
 * in the case of an error, to restart a conversion from a known default state.
439
 
 * It will also empty the internal output buffers.
440
 
 * @param converter the Unicode converter
441
 
 * @stable
442
 
 */
443
 
U_CAPI void U_EXPORT2
444
 
ucnv_reset (UConverter * converter);
445
 
 
446
 
/**
447
 
 * Resets the to-Unicode part of a converter state to the default state.
448
 
 * This is used in the case of an error to restart a conversion to
449
 
 * Unicode to a known default state. It will also empty the internal
450
 
 * output buffers used for the conversion to Unicode codepoints.
451
 
 * @param converter the Unicode converter
452
 
 * @draft ICU 1.8
453
 
 */
454
 
U_CAPI void U_EXPORT2 
455
 
ucnv_resetToUnicode(UConverter *converter);
456
 
 
457
 
/**
458
 
 * Resets the from-Unicode part of a converter state to the default state.
459
 
 * This is used in the case of an error to restart a conversion from
460
 
 * Unicode to a known default state. It will also empty the internal output
461
 
 * buffers used for the conversion from Unicode codepoints.
462
 
 * @param converter the Unicode converter
463
 
 * @draft ICU 1.8
464
 
 */
465
 
U_CAPI void U_EXPORT2 
466
 
ucnv_resetFromUnicode(UConverter *converter);
467
 
 
468
 
/**
469
 
 * Returns the maximum length of bytes used by a character. This varies 
470
 
 * between 1 and 4
471
 
 * @param converter the Unicode converter
472
 
 * @return the maximum number of bytes allowed by this particular converter
473
 
 * @see ucnv_getMinCharSize
474
 
 * @stable
475
 
 */
476
 
U_CAPI int8_t U_EXPORT2
477
 
ucnv_getMaxCharSize (const UConverter * converter);
478
 
 
479
 
 
480
 
/**
481
 
 * Returns the minimum byte length for characters in this codepage. 
482
 
 * This is either 1 or 2 for all supported codepages.
483
 
 * @param converter the Unicode converter
484
 
 * @return the minimum number of bytes allowed by this particular converter
485
 
 * @see ucnv_getMaxCharSize
486
 
 * @stable
487
 
 */
488
 
U_CAPI int8_t U_EXPORT2
489
 
ucnv_getMinCharSize (const UConverter * converter);
490
 
 
491
 
/**
492
 
 * Returns the display name of the converter passed in based on the Locale 
493
 
 * passed in. If the locale contains no display name, the internal ASCII
494
 
 * name will be filled in.
495
 
 *
496
 
 * @param converter the Unicode converter.
497
 
 * @param displayLocale is the specific Locale we want to localised for
498
 
 * @param displayName user provided buffer to be filled in
499
 
 * @param displayNameCapacty size of displayName Buffer
500
 
 * @param err error status code
501
 
 * @return displayNameLength number of UChar needed in displayName
502
 
 * @see ucnv_getName
503
 
 * @stable
504
 
 */
505
 
U_CAPI int32_t U_EXPORT2
506
 
ucnv_getDisplayName (const UConverter * converter,
507
 
                     const char *displayLocale,
508
 
                     UChar * displayName,
509
 
                     int32_t displayNameCapacity,
510
 
                     UErrorCode * err);
511
 
 
512
 
/**
513
 
 * Gets the internal, canonical name of the converter (zero-terminated).
514
 
 * The lifetime of the returned string will be that of the converter 
515
 
 * passed to this function.
516
 
 * @param converter the Unicode converter
517
 
 * @param err UErrorCode status
518
 
 * @return the internal name of the converter
519
 
 * @see ucnv_getDisplayName
520
 
 * @stable
521
 
 */
522
 
U_CAPI const char * U_EXPORT2 
523
 
ucnv_getName (const UConverter * converter, UErrorCode * err);
524
 
 
525
 
 
526
 
/**
527
 
 * Gets a codepage number associated with the converter. This is not guaranteed
528
 
 * to be the one used to create the converter. Some converters do not represent
529
 
 * platform registered codepages and return zero for the codepage number.
530
 
 * The error code fill-in parameter indicates if the codepage number
531
 
 * is available.
532
 
 * Does not check if the converter is <TT>NULL</TT> or if converter's data
533
 
 * table is <TT>NULL</TT>.
534
 
 *
535
 
 * Important: The use of CCSIDs is not recommended because it is limited
536
 
 * to only two platforms in principle and only one (UCNV_IBM) in the current
537
 
 * ICU converter API.
538
 
 * Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely.
539
 
 * For more details see ucnv_openCCSID().
540
 
 *
541
 
 * @param converter the Unicode converter
542
 
 * @param err the error status code.
543
 
 * @return If any error occurrs, -1 will be returned otherwise, the codepage number
544
 
 * will be returned
545
 
 * @see ucnv_openCCSID
546
 
 * @see ucnv_getPlatform
547
 
 * @stable
548
 
 */
549
 
U_CAPI int32_t U_EXPORT2
550
 
ucnv_getCCSID (const UConverter * converter,
551
 
               UErrorCode * err);
552
 
 
553
 
/**
554
 
 * Gets a codepage platform associated with the converter. Currently, 
555
 
 * only <TT>UCNV_IBM</TT> will be returned.
556
 
 * Does not test if the converter is <TT>NULL</TT> or if converter's data 
557
 
 * table is <TT>NULL</TT>. 
558
 
 * @param converter the Unicode converter
559
 
 * @param err the error status code.
560
 
 * @return The codepage platform
561
 
 * @stable
562
 
 */
563
 
U_CAPI UConverterPlatform U_EXPORT2
564
 
ucnv_getPlatform (const UConverter * converter,
565
 
                  UErrorCode * err);
566
 
 
567
 
/**
568
 
 * Gets the type of the converter
569
 
 * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, 
570
 
 * EBCDIC_STATEFUL, LATIN_1
571
 
 * @param converter a valid, opened converter
572
 
 * @return the type of the converter
573
 
 * @stable
574
 
 */
575
 
U_CAPI UConverterType U_EXPORT2
576
 
ucnv_getType (const UConverter * converter);
577
 
 
578
 
/**
579
 
 * Gets the "starter" (lead) bytes for converters of type MBCS.
580
 
 * Will fill in an <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if converter passed in
581
 
 * is not MBCS. Fills in an array of type UBool, with the value of the byte 
582
 
 * as offset to the array. For example, if (starters[0x20] == TRUE) at return,
583
 
 * it means that the byte 0x20 is a starter byte in this converter.
584
 
 * Context pointers are always owned by the caller.
585
 
 * 
586
 
 * @param converter a valid, opened converter of type MBCS
587
 
 * @param starters an array of size 256 to be filled in
588
 
 * @param err error status, <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if the 
589
 
 * converter is not a type which can return starters.
590
 
 * @see ucnv_getType
591
 
 * @stable
592
 
 */
593
 
U_CAPI void U_EXPORT2 ucnv_getStarters(const UConverter* converter, 
594
 
                                       UBool starters[256],
595
 
                                       UErrorCode* err);
596
 
 
597
 
 
598
 
/**
599
 
 * Gets the current calback function used by the converter when an illegal
600
 
 *  or invalid codepage sequence is found. 
601
 
 * Context pointers are always owned by the caller.
602
 
 *
603
 
 * @param converter the unicode converter
604
 
 * @param action fillin: returns the callback function pointer
605
 
 * @param context fillin: returns the callback's private void* context
606
 
 * @see ucnv_setToUCallBack
607
 
 * @stable
608
 
 */
609
 
U_CAPI void U_EXPORT2
610
 
ucnv_getToUCallBack (const UConverter * converter,
611
 
                     UConverterToUCallback *action,
612
 
                     const void **context);
613
 
 
614
 
/**
615
 
 * Gets the current callback function used by the converter when illegal 
616
 
 * or invalid Unicode sequence is found.
617
 
 * Context pointers are always owned by the caller.
618
 
 *
619
 
 * @param converter the unicode converter
620
 
 * @param action fillin: returns the callback function pointer
621
 
 * @param context fillin: returns the callback's private void* context
622
 
 * @see ucnv_setFromUCallBack
623
 
 * @stable
624
 
 */
625
 
U_CAPI void U_EXPORT2
626
 
ucnv_getFromUCallBack (const UConverter * converter,
627
 
                       UConverterFromUCallback *action,
628
 
                       const void **context);
629
 
 
630
 
/**
631
 
 * Changes the callback function used by the converter when
632
 
 * an illegal or invalid sequence is found.
633
 
 * Context pointers are always owned by the caller.
634
 
 *
635
 
 * @param converter the unicode converter
636
 
 * @param newAction the new callback function
637
 
 * @param newContext the new toUnicode callback context pointer
638
 
 * @param oldAction fillin: returns the old callback function pointer
639
 
 * @param oldContext fillin: returns the old callback's private void* context
640
 
 * @param err The error code status
641
 
 * @see ucnv_getToUCallBack
642
 
 * @stable
643
 
 */
644
 
U_CAPI void U_EXPORT2
645
 
ucnv_setToUCallBack (UConverter * converter,
646
 
                     UConverterToUCallback newAction,
647
 
                     const void* newContext,
648
 
                     UConverterToUCallback *oldAction,
649
 
                     const void** oldContext,
650
 
                     UErrorCode * err);
651
 
 
652
 
/**
653
 
 * Changes the current callback function used by the converter when
654
 
 * an illegal or invalid sequence is found.
655
 
 * Context pointers are always owned by the caller.
656
 
 *
657
 
 * @param converter the unicode converter
658
 
 * @param newAction the new callback function
659
 
 * @param newContext the new fromUnicode callback context pointer
660
 
 * @param oldAction fillin: returns the old callback function pointer
661
 
 * @param oldContext fillin: returns the old callback's private void* context
662
 
 * @param err The error code status
663
 
 * @see ucnv_getFromUCallBack
664
 
 * @stable
665
 
 */
666
 
U_CAPI void U_EXPORT2
667
 
ucnv_setFromUCallBack (UConverter * converter,
668
 
                       UConverterFromUCallback newAction,
669
 
                       const void *newContext,
670
 
                       UConverterFromUCallback *oldAction,
671
 
                       const void **oldContext,
672
 
                       UErrorCode * err);
673
 
 
674
 
/**
675
 
 * Converts an array of unicode characters to an array of codepage
676
 
 * characters. This function is optimized for converting a continuous
677
 
 * stream of data in buffer-sized chunks, where the entire source and
678
 
 * target does not fit in available buffers.
679
 
 * 
680
 
 * The source pointer is an in/out parameter. It starts out pointing where the 
681
 
 * conversion is to begin, and ends up pointing after the last UChar consumed. 
682
 
 * 
683
 
 * Target similarly starts out pointer at the first available byte in the output
684
 
 * buffer, and ends up pointing after the last byte written to the output.
685
 
 * 
686
 
 * The converter always attempts to consume the entire source buffer, unless 
687
 
 * (1.) the target buffer is full, or (2.) a failing error is returned from the
688
 
 * current callback function.  When a successful error status has been
689
 
 * returned, it means that all of the source buffer has been
690
 
 *  consumed. At that point, the caller should reset the source and
691
 
 *  sourceLimit pointers to point to the next chunk.
692
 
 * 
693
 
 * This is a <I>stateful</I> conversion. Additionally, even when all source data has
694
 
 * been consumed, some data may be in the converters' internal state.
695
 
 * Call this function repeatedly, updating the target pointers with
696
 
 * the next empty chunk of target in case of a
697
 
 * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers
698
 
 *  with the next chunk of source when a successful error status is
699
 
 * returned, until there are no more chunks of source data.
700
 
 * @param converter the Unicode converter
701
 
 * @param target I/O parameter. Input : Points to the beginning of the buffer to copy
702
 
 *  codepage characters to. Output : points to after the last codepage character copied
703
 
 *  to <TT>target</TT>.
704
 
 * @param targetLimit the pointer just after last of the <TT>target</TT> buffer
705
 
 * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. 
706
 
 * @param sourceLimit the pointer just after the last of the source buffer
707
 
 * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
708
 
 * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
709
 
 * 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>
710
 
 * For output data carried across calls, and other data without a specific source character
711
 
 * (such as from escape sequences or callbacks)  -1 will be placed for offsets. 
712
 
 * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
713
 
 * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
714
 
 * this function may have to be called multiple times wiht flush set to <TT>TRUE</TT> until
715
 
 * the source buffer is consumed.
716
 
 * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
717
 
 * converter is <TT>NULL</TT>.
718
 
 * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is 
719
 
 * still data to be written to the target.
720
 
 * @see ucnv_fromUChars
721
 
 * @see ucnv_convert
722
 
 * @see ucnv_getMinCharSize
723
 
 * @see ucnv_setToUCallBack
724
 
 * @stable
725
 
 */
726
 
U_CAPI void U_EXPORT2 
727
 
ucnv_fromUnicode (UConverter * converter,
728
 
                  char **target,
729
 
                  const char *targetLimit,
730
 
                  const UChar ** source,
731
 
                  const UChar * sourceLimit,
732
 
                  int32_t* offsets,
733
 
                  UBool flush,
734
 
                  UErrorCode * err);
735
 
 
736
 
/**
737
 
 * Converts a buffer of codepage bytes into an array of unicode UChars
738
 
 * characters. This function is optimized for converting a continuous
739
 
 * stream of data in buffer-sized chunks, where the entire source and
740
 
 * target does not fit in available buffers.
741
 
 * 
742
 
 * The source pointer is an in/out parameter. It starts out pointing where the 
743
 
 * conversion is to begin, and ends up pointing after the last byte of source consumed. 
744
 
 * 
745
 
 * Target similarly starts out pointer at the first available UChar in the output
746
 
 * buffer, and ends up pointing after the last UChar written to the output. 
747
 
 * It does NOT necessarily keep UChar sequences together.
748
 
 * 
749
 
 * The converter always attempts to consume the entire source buffer, unless 
750
 
 * (1.) the target buffer is full, or (2.) a failing error is returned from the
751
 
 * current callback function.  When a successful error status has been
752
 
 * returned, it means that all of the source buffer has been
753
 
 *  consumed. At that point, the caller should reset the source and
754
 
 *  sourceLimit pointers to point to the next chunk.
755
 
 * 
756
 
 * This is a <I>stateful</I> conversion. Additionally, even when all source data has
757
 
 * been consumed, some data may be in the converters' internal state.
758
 
 * Call this function repeatedly, updating the target pointers with
759
 
 * the next empty chunk of target in case of a
760
 
 * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers
761
 
 *  with the next chunk of source when a successful error status is
762
 
 * returned, until there are no more chunks of source data.
763
 
 * @param converter the Unicode converter
764
 
 * @param target I/O parameter. Input : Points to the beginning of the buffer to copy
765
 
 *  UChars into. Output : points to after the last UChar copied.
766
 
 * @param targetLimit the pointer just after the end of the <TT>target</TT> buffer
767
 
 * @param source I/O parameter, pointer to pointer to the source codepage buffer. 
768
 
 * @param sourceLimit the pointer to the byte after the end of the source buffer
769
 
 * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
770
 
 * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
771
 
 * 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>
772
 
 * For output data carried across calls, and other data without a specific source character
773
 
 * (such as from escape sequences or callbacks)  -1 will be placed for offsets. 
774
 
 * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
775
 
 * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
776
 
 * this function may have to be called multiple times wiht flush set to <TT>TRUE</TT> until
777
 
 * the source buffer is consumed.
778
 
 * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
779
 
 * converter is <TT>NULL</TT>.
780
 
 * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is 
781
 
 * still data to be written to the target. 
782
 
 * @see ucnv_fromUChars
783
 
 * @see ucnv_convert
784
 
 * @see ucnv_getMinCharSize
785
 
 * @see ucnv_setFromUCallBack
786
 
 * @see ucnv_getNextUChar
787
 
 * @stable
788
 
 */
789
 
U_CAPI void U_EXPORT2 
790
 
ucnv_toUnicode (UConverter * converter,
791
 
                UChar ** target,
792
 
                const UChar * targetLimit,
793
 
                const char **source,
794
 
                const char *sourceLimit,
795
 
                int32_t* offsets,
796
 
                UBool flush,
797
 
                UErrorCode * err);
798
 
 
799
 
 
800
 
/**
801
 
 * Convert the Unicode string into a codepage string using an existing UConverter.
802
 
 * The output string is NUL-terminated if possible.
803
 
 *
804
 
 * This function is a more convenient but less powerful version of ucnv_fromUnicode().
805
 
 * It is only useful for whole strings, not for streaming conversion.
806
 
 *
807
 
 * The maximum output buffer capacity required (barring output from callbacks) will be
808
 
 * srcLength*ucnv_getMaxCharSize(cnv).
809
 
 *
810
 
 * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called)
811
 
 * @param src the input Unicode string
812
 
 * @param srcLength the input string length, or -1 if NUL-terminated
813
 
 * @param dest destination string buffer, can be NULL if destCapacity==0
814
 
 * @param destCapacity the number of chars available at dest
815
 
 * @param errorCode normal ICU error code;
816
 
 *                  common error codes that may be set by this function include
817
 
 *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
818
 
 *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
819
 
 * @return the length of the output string, not counting the terminating NUL;
820
 
 *         if the length is greater than destCapacity, then the string will not fit
821
 
 *         and a buffer of the indicated length would need to be passed in
822
 
 * @see ucnv_fromUnicode
823
 
 * @see ucnv_convert
824
 
 * @draft ICU 2.0 (new NUL-termination semantics)
825
 
 */
826
 
U_CAPI int32_t U_EXPORT2
827
 
ucnv_fromUChars(UConverter *cnv,
828
 
                char *dest, int32_t destCapacity,
829
 
                const UChar *src, int32_t srcLength,
830
 
                UErrorCode *pErrorCode);
831
 
 
832
 
 
833
 
/**
834
 
 * Convert the codepage string into a Unicode string using an existing UConverter.
835
 
 * The output string is NUL-terminated if possible.
836
 
 *
837
 
 * This function is a more convenient but less powerful version of ucnv_toUnicode().
838
 
 * It is only useful for whole strings, not for streaming conversion.
839
 
 *
840
 
 * The maximum output buffer capacity required (barring output from callbacks) will be
841
 
 * 2*srcLength (each char may be converted into a surrogate pair).
842
 
 *
843
 
 * @param cnv the converter object to be used (ucnv_resetToUnicode() will be called)
844
 
 * @param src the input codepage string
845
 
 * @param srcLength the input string length, or -1 if NUL-terminated
846
 
 * @param dest destination string buffer, can be NULL if destCapacity==0
847
 
 * @param destCapacity the number of UChars available at dest
848
 
 * @param errorCode normal ICU error code;
849
 
 *                  common error codes that may be set by this function include
850
 
 *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
851
 
 *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
852
 
 * @return the length of the output string, not counting the terminating NUL;
853
 
 *         if the length is greater than destCapacity, then the string will not fit
854
 
 *         and a buffer of the indicated length would need to be passed in
855
 
 * @see ucnv_toUnicode
856
 
 * @see ucnv_convert
857
 
 * @draft ICU 2.0 (new NUL-termination semantics)
858
 
 */
859
 
U_CAPI int32_t U_EXPORT2
860
 
ucnv_toUChars(UConverter *cnv,
861
 
              UChar *dest, int32_t destCapacity,
862
 
              const char *src, int32_t srcLength,
863
 
              UErrorCode *pErrorCode);
864
 
 
865
 
/**
866
 
 * Will convert a codepage buffer into unicode one character at a time.
867
 
 * <p>This function was written to be efficient when transcoding small
868
 
 * amounts of data at a time.
869
 
 * In that case it will be more efficient than \Ref{ucnv_toUnicode}.
870
 
 * When converting large buffers use \Ref{ucnv_toUnicode}.</p>
871
 
 *
872
 
 * <p>Handling of surrogate pairs and supplementary-plane code points:<br>
873
 
 * There are two different kinds of codepages that provide mappings for surrogate characters:
874
 
 * <ul>
875
 
 *   <li>Codepages like UTF-8, UTF-32, and GB 18030 provide direct representations for Unicode
876
 
 *       code points U+10000-U+10ffff as well as for single surrogates U+d800-U+dfff.
877
 
 *       Each valid sequence will result in exactly one returned code point.
878
 
 *       If a sequence results in a single surrogate, then that will be returned
879
 
 *       by itself, even if a neighboring sequence encodes the matching surrogate.</li>
880
 
 *   <li>Codepages like SCSU and LMBCS (and UTF-16) provide direct representations only for BMP code points
881
 
 *       including surrogates. Code points in supplementary planes are represented with
882
 
 *       two sequences, each encoding a surrogate.
883
 
 *       For these codepages, matching pairs of surrogates will be combined into single
884
 
 *       code points for returning from this function.
885
 
 *       (Note that SCSU is actually a mix of these codepage types.)</li>
886
 
 * </ul></p>
887
 
 *
888
 
 * @param converter an open UConverter
889
 
 * @param source the address of a pointer to the codepage buffer, will be
890
 
 *  updated to point after the bytes consumed in the conversion call.
891
 
 * @param sourceLimit points to the end of the input buffer
892
 
 * @param err fills in error status (see ucnv_toUnicode)
893
 
 * <code>U_INDEX_OUTOFBOUNDS_ERROR</code> will be set if the input 
894
 
 * is empty or does not convert to any output (e.g.: pure state-change 
895
 
 * codes SI/SO, escape sequences for ISO 2022,
896
 
 * or if the callback did not output anything, ...).
897
 
 * This function will not set a <code>U_BUFFER_OVERFLOW_ERROR</code> because
898
 
 *  the "buffer" is the return code. However, there might be subsequent output
899
 
 *  stored in the converter object
900
 
 * that will be returned in following calls to this function.
901
 
 * @return a UChar32 resulting from the partial conversion of source
902
 
 * @see ucnv_toUnicode
903
 
 * @see ucnv_toUChars
904
 
 * @see ucnv_convert
905
 
 * @stable
906
 
 */
907
 
U_CAPI UChar32 U_EXPORT2
908
 
ucnv_getNextUChar (UConverter * converter,
909
 
                   const char **source,
910
 
                   const char * sourceLimit,
911
 
                   UErrorCode * err);
912
 
 
913
 
 
914
 
/**
915
 
 * Will convert a sequence of bytes from one codepage to another.
916
 
 * This is <STRONG>NOT AN EFFICIENT</STRONG> way to transcode.
917
 
 * use \Ref{ucnv_toUnicode} and \Ref{ucnv_fromUnicode} for efficiency.
918
 
 * @param toConverterName The name of the converter that will be used
919
 
 *  in conversion from unicode into the output buffer
920
 
 * @param fromConverterName: The name of the converter that will be used
921
 
 *  in conversion from the source buffer into intermediate unicode.
922
 
 * @param target Pointer to the output buffer
923
 
 * @param targetCapacity capacity of the target, in bytes
924
 
 * @param source Pointer to the input buffer
925
 
 * @param sourceLength capacity of the source, in bytes
926
 
 * @param err error status. 
927
 
 * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is still input left in the source.
928
 
 * @return  will be filled in with the number of bytes needed in target
929
 
 * @see ucnv_fromUnicode
930
 
 * @see ucnv_toUnicode
931
 
 * @see ucnv_fromUChars
932
 
 * @see ucnv_toUChars
933
 
 * @see ucnv_getNextUChar
934
 
 * @stable
935
 
 */
936
 
U_CAPI int32_t U_EXPORT2
937
 
ucnv_convert (const char *toConverterName,
938
 
              const char *fromConverterName,
939
 
              char *target,
940
 
              int32_t targetCapacity,
941
 
              const char *source,
942
 
              int32_t sourceLength,
943
 
              UErrorCode * err);
944
 
 
945
 
/**
946
 
 * Frees up memory occupied by unused, cached converter shared data.
947
 
 *
948
 
 * @return the number of cached converters successfully deleted
949
 
 * @see ucnv_close
950
 
 * @stable
951
 
 */
952
 
U_CAPI int32_t U_EXPORT2
953
 
ucnv_flushCache (void);
954
 
 
955
 
 
956
 
/**
957
 
 * returns the number of available converters, as per the alias file.
958
 
 *
959
 
 * @return the number of available converters
960
 
 * @see ucnv_getAvailableName
961
 
 * @stable
962
 
 */
963
 
U_CAPI int32_t U_EXPORT2
964
 
ucnv_countAvailable (void);
965
 
 
966
 
/**
967
 
 * Gets the name of the specified converter from a list of all converters
968
 
 * contaied in the alias file.
969
 
 * @param n the index to a converter available on the system (in the range <TT>[0..ucnv_countAvaiable()]</TT>)
970
 
 * @return a pointer a string (library owned), or <TT>NULL</TT> if the index is out of bounds.
971
 
 * @see ucnv_countAvailable
972
 
 * @stable
973
 
 */
974
 
U_CAPI const char* U_EXPORT2
975
 
ucnv_getAvailableName (int32_t n);
976
 
 
977
 
/**
978
 
 * Gives the number of aliases for a given converter or alias name.
979
 
 * Note that additional aliases are recognized by ucnv_open().
980
 
 * This method only enumerates the listed entries in the alias file.
981
 
 * @param alias alias name
982
 
 * @param pErrorCode error status
983
 
 * @return number of names on alias list for given alias
984
 
 * @stable
985
 
 */
986
 
U_CAPI uint16_t U_EXPORT2 
987
 
ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
988
 
 
989
 
/**
990
 
 * Gives the name of the alias at given index of alias list.
991
 
 * Note that additional aliases are recognized by ucnv_open().
992
 
 * This method only enumerates the listed entries in the alias file.
993
 
 * @param alias alias name
994
 
 * @param n index in alias list
995
 
 * @param pErrorCode result of operation
996
 
 * @return returns the name of the alias at given index
997
 
 * @see ucnv_countAliases
998
 
 * @stable
999
 
 */
1000
 
U_CAPI const char * U_EXPORT2 
1001
 
ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
1002
 
 
1003
 
/**
1004
 
 * Fill-up the list of alias names for the given alias.
1005
 
 * Note that additional aliases are recognized by ucnv_open().
1006
 
 * This method only enumerates the listed entries in the alias file.
1007
 
 * @param alias alias name
1008
 
 * @param aliases fill-in list, aliases is a pointer to an array of
1009
 
 *        <code>ucnv_countAliases()</code> string-pointers
1010
 
 *        (<code>const char *</code>) that will be filled in.
1011
 
 *        The strings themselves are owned by the library.
1012
 
 * @param pErrorCode result of operation
1013
 
 * @stable
1014
 
 */
1015
 
U_CAPI void U_EXPORT2 
1016
 
ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
1017
 
 
1018
 
/**
1019
 
 * Gives the number of standards associated to converter names.
1020
 
 * @return number of standards
1021
 
 * @stable
1022
 
 */
1023
 
U_CAPI uint16_t U_EXPORT2
1024
 
ucnv_countStandards(void);
1025
 
 
1026
 
/**
1027
 
 * Gives the name of the standard at given index of standard list.
1028
 
 * @param n index in standard list
1029
 
 * @param pErrorCode result of operation
1030
 
 * @return returns the name of the standard at given index. Owned by the library.
1031
 
 * @stable
1032
 
 */
1033
 
U_CAPI const char * U_EXPORT2
1034
 
ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
1035
 
 
1036
 
/**
1037
 
 * Returns a standard name for a given converter name.
1038
 
 *
1039
 
 * @param name original converter name
1040
 
 * @param standard name of the standard governing the names; MIME and IANA
1041
 
 *        are such standards
1042
 
 * @return returns the standard converter name;
1043
 
 *         if a standard converter name cannot be determined,
1044
 
 *         then <code>NULL</code> is returned. Owned by the library.
1045
 
 * @stable
1046
 
 */
1047
 
U_CAPI const char * U_EXPORT2
1048
 
ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
1049
 
 
1050
 
/**
1051
 
 * returns the current default converter name.
1052
 
 *
1053
 
 * @return returns the current default converter name;
1054
 
 *         if a default converter name cannot be determined,
1055
 
 *         then <code>NULL</code> is returned.
1056
 
 *         Storage owned by the library
1057
 
 * @see ucnv_setDefaultName
1058
 
 * @stable
1059
 
 */
1060
 
U_CAPI const char * U_EXPORT2
1061
 
ucnv_getDefaultName (void);
1062
 
 
1063
 
/**
1064
 
 * sets the current default converter name. Caller must own the storage for 'name'
1065
 
 * and preserve it indefinitely. 
1066
 
 * @param name the converter name to be the default (must exist).
1067
 
 * @see ucnv_getDefaultName
1068
 
 * @system SYSTEM API
1069
 
 * @stable
1070
 
 */
1071
 
U_CAPI void U_EXPORT2
1072
 
ucnv_setDefaultName (const char *name);
1073
 
 
1074
 
/**
1075
 
 * Fixes the backslash character mismapping.  For example, in SJIS, the backslash 
1076
 
 * character in the ASCII portion is also used to represent the yen currency sign.  
1077
 
 * When mapping from Unicode character 0x005C, it's unclear whether to map the 
1078
 
 * character back to yen or backslash in SJIS.  This function will take the input
1079
 
 * buffer and replace all the yen sign characters with backslash.  This is necessary
1080
 
 * when the user tries to open a file with the input buffer on Windows.
1081
 
 * This function will test the converter to see whether such mapping is
1082
 
 * required.  You can sometimes avoid using this function by using the correct version
1083
 
 * of Shift-JIS.
1084
 
 *
1085
 
 * @param cnv The converter representing the target codepage.
1086
 
 * @param source the input buffer to be fixed
1087
 
 * @param sourceLength the length of the input buffer
1088
 
 * @see ucnv_isAmbiguous
1089
 
 * @stable
1090
 
 */
1091
 
U_CAPI void U_EXPORT2
1092
 
ucnv_fixFileSeparator(const UConverter *cnv, UChar* source, int32_t sourceLen);
1093
 
 
1094
 
/**
1095
 
 * Determines if the converter contains ambiguous mappings of the same
1096
 
 * character or not.
1097
 
 * @return TRUE if the converter contains ambiguous mapping of the same 
1098
 
 * character, FALSE otherwise.
1099
 
 * @stable
1100
 
 */
1101
 
U_CAPI UBool U_EXPORT2
1102
 
ucnv_isAmbiguous(const UConverter *cnv);
1103
 
 
1104
 
/**
1105
 
 * Sets the converter to use fallback mapping or not.
1106
 
 * @param cnv The converter to set the fallback mapping usage on.
1107
 
 * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback 
1108
 
 * mapping, FALSE otherwise.
1109
 
 * @stable
1110
 
 */
1111
 
U_CAPI void U_EXPORT2 
1112
 
ucnv_setFallback(UConverter *cnv, UBool usesFallback);
1113
 
 
1114
 
/**
1115
 
 * Determines if the converter uses fallback mappings or not.
1116
 
 * @return TRUE if the converter uses fallback, FALSE otherwise.
1117
 
 * @stable
1118
 
 */
1119
 
U_CAPI UBool U_EXPORT2 
1120
 
ucnv_usesFallback(const UConverter *cnv);
1121
 
 
1122
 
/**
1123
 
 * Detects Unicode signatures in the given byte stream. The signature bytes are not consumed, 
1124
 
 * instead the number of bytes that make up the signature is returned. The conversion APIs
1125
 
 * donot discard signature bytes, so if the caller wishes to discard them, the caller should 
1126
 
 * explicity add code to do that after calling this function.
1127
 
 * <p>
1128
 
 * Usage:
1129
 
 * @code     
1130
 
 *      UErrorCode err = U_ZERO_ERROR;
1131
 
 *      char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' };
1132
 
 *      char* source = input;
1133
 
 *      int32_t signatureLength = 0;
1134
 
 *      char* encoding = ucnv_detectUnicodeSignatures(source,sizeof(input),&signatureLength,&err);
1135
 
 *      UConverter* conv = NULL;
1136
 
 *      if(encoding!=NULL && U_SUCCESS(err)){
1137
 
 *          // should signature be discarded ?
1138
 
 *          if (discardSignature){
1139
 
 *              source += signatureLength;
1140
 
 *          }
1141
 
 *          conv = ucnv_open(encoding, &err);
1142
 
 *          .... do the conversion ....
1143
 
 *      }
1144
 
 *     
1145
 
 * @endcode
1146
 
 *
1147
 
 * @param source            The source string in which the signature should be detected.
1148
 
 * @param sourceLength      Length of the input string, or -1 if NUL-terminated.
1149
 
 * @param signatureLength   A pointer to int8_t to receive the number of bytes that make up the signature 
1150
 
 *                          of the detected UTF. 0 if not detected.
1151
 
 * @param pErrorCode        A pointer to receive information about any errors that may occur during detection.
1152
 
 *                          Must be a valid pointer to an error code value, which must not indicate a failure
1153
 
 *                          before the function call.
1154
 
 * @return The name of the encoding detected. NULL if encoding is not detected. 
1155
 
 */
1156
 
U_CAPI const char* U_EXPORT2
1157
 
ucnv_detectUnicodeSignature( const char* source,
1158
 
                             int32_t sourceLength,
1159
 
                             int32_t* signatureLength,
1160
 
                             UErrorCode* pErrorCode);
1161
 
 
1162
 
#endif
1163
 
/*_UCNV*/
1164