]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/ucnv_imp.h
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / common / ucnv_imp.h
CommitLineData
b75a7d8f
A
1/*
2**********************************************************************
729e4ab9 3* Copyright (C) 1999-2009, International Business Machines
b75a7d8f
A
4* Corporation and others. All Rights Reserved.
5**********************************************************************
6*
7*
8* ucnv_imp.h:
9* Contains all internal and external data structure definitions
10* Created & Maitained by Bertrand A. Damiba
11*
12*
13*
14* ATTENTION:
15* ---------
16* Although the data structures in this file are open and stack allocatable
17* we reserve the right to hide them in further releases.
18*/
19
20#ifndef UCNV_IMP_H
21#define UCNV_IMP_H
22
23#include "unicode/utypes.h"
374ca955
A
24
25#if !UCONFIG_NO_CONVERSION
26
27#include "unicode/uloc.h"
b75a7d8f
A
28#include "ucnv_bld.h"
29
729e4ab9
A
30/*
31 * Fast check for whether a charset name is "UTF-8".
32 * This does not recognize all of the variations that ucnv_open()
33 * and other functions recognize, but it covers most cases.
34 * @param name const char * charset name
35 * @return
36 */
37#define UCNV_FAST_IS_UTF8(name) \
38 (((name[0]=='U' ? \
39 ( name[1]=='T' && name[2]=='F') : \
40 (name[0]=='u' && name[1]=='t' && name[2]=='f'))) \
41 && (name[3]=='-' ? \
42 (name[4]=='8' && name[5]==0) : \
43 (name[3]=='8' && name[4]==0)))
44
45typedef struct {
46 char cnvName[UCNV_MAX_CONVERTER_NAME_LENGTH];
47 char locale[ULOC_FULLNAME_CAPACITY];
48 uint32_t options;
49} UConverterNamePieces;
50
51U_CFUNC UBool
52ucnv_canCreateConverter(const char *converterName, UErrorCode *err);
53
b75a7d8f
A
54/* figures out if we need to go to file to read in the data tables.
55 * @param converterName The name of the converter
56 * @param err The error code
57 * @return the newly created converter
58 */
59UConverter *ucnv_createConverter (UConverter *myUConverter, const char *converterName, UErrorCode * err);
60
61/*
62 * Open a purely algorithmic converter, specified by a type constant.
63 * @param myUConverter NULL, or pre-allocated UConverter structure to avoid
64 * a memory allocation
65 * @param type requested converter type
66 * @param locale locale parameter, or ""
67 * @param options converter options bit set (default 0)
68 * @param err ICU error code, not tested for U_FAILURE on input
69 * because this is an internal function
70 * @internal
71 */
72U_CFUNC UConverter *
73ucnv_createAlgorithmicConverter(UConverter *myUConverter,
74 UConverterType type,
75 const char *locale, uint32_t options,
76 UErrorCode *err);
77
729e4ab9
A
78/*
79 * Creates a converter from shared data.
80 * Adopts mySharedConverterData: No matter what happens, the caller must not
81 * unload mySharedConverterData, except via ucnv_close(return value)
82 * if this function is successful.
b75a7d8f
A
83 */
84UConverter*
729e4ab9
A
85ucnv_createConverterFromSharedData(UConverter *myUConverter,
86 UConverterSharedData *mySharedConverterData,
87 UConverterLoadArgs *pArgs,
88 UErrorCode *err);
b75a7d8f
A
89
90UConverter* ucnv_createConverterFromPackage(const char *packageName, const char *converterName,
91 UErrorCode *err);
92
374ca955
A
93/**
94 * Load a converter but do not create a UConverter object.
95 * Simply return the UConverterSharedData.
96 * Performs alias lookup etc.
729e4ab9
A
97 * The UConverterNamePieces need not be initialized
98 * before calling this function.
99 * The UConverterLoadArgs must be initialized
100 * before calling this function.
101 * If the args are passed in, then the pieces must be passed in too.
102 * In other words, the following combinations are allowed:
103 * - pieces==NULL && args==NULL
104 * - pieces!=NULL && args==NULL
105 * - pieces!=NULL && args!=NULL
374ca955
A
106 * @internal
107 */
108UConverterSharedData *
729e4ab9
A
109ucnv_loadSharedData(const char *converterName,
110 UConverterNamePieces *pieces,
111 UConverterLoadArgs *pArgs,
112 UErrorCode * err);
374ca955 113
b75a7d8f
A
114/**
115 * This may unload the shared data in a thread safe manner.
116 * This will only unload the data if no other converters are sharing it.
117 */
118void
119ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData);
120
121/**
122 * This is a thread safe way to increment the reference count.
123 */
124void
125ucnv_incrementRefCount(UConverterSharedData *sharedData);
126
46f4442e
A
127/**
128 * These are the default error handling callbacks for the charset conversion framework.
129 * For performance reasons, they are only called to handle an error (not normally called for a reset or close).
130 */
73c04bcf
A
131#define UCNV_TO_U_DEFAULT_CALLBACK ((UConverterToUCallback) UCNV_TO_U_CALLBACK_SUBSTITUTE)
132#define UCNV_FROM_U_DEFAULT_CALLBACK ((UConverterFromUCallback) UCNV_FROM_U_CALLBACK_SUBSTITUTE)
b75a7d8f 133
374ca955 134#endif
b75a7d8f
A
135
136#endif /* _UCNV_IMP */