]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/unicode/ulocdata.h
ICU-491.11.3.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / ulocdata.h
CommitLineData
374ca955
A
1/*
2******************************************************************************
3* *
4388f060 4* Copyright (C) 2003-2012, International Business Machines *
374ca955
A
5* Corporation and others. All Rights Reserved. *
6* *
7******************************************************************************
8* file name: ulocdata.h
9* encoding: US-ASCII
10* tab size: 8 (not used)
11* indentation:4
12*
13* created on: 2003Oct21
14* created by: Ram Viswanadha
15*/
16
17#ifndef __ULOCDATA_H__
18#define __ULOCDATA_H__
19
20#include "unicode/ures.h"
21#include "unicode/uloc.h"
22#include "unicode/uset.h"
729e4ab9 23#include "unicode/localpointer.h"
374ca955 24
73c04bcf
A
25/**
26 * \file
729e4ab9 27 * \brief C API: Provides access to locale data.
73c04bcf
A
28 */
29
46f4442e 30/** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */
73c04bcf
A
31struct ULocaleData;
32
46f4442e 33/** A locale data object. @stable ICU 3.6 */
73c04bcf
A
34typedef struct ULocaleData ULocaleData;
35
36
37
38/** The possible types of exemplar character sets.
46f4442e 39 * @stable ICU 3.4
73c04bcf
A
40 */
41typedef enum ULocaleDataExemplarSetType {
4388f060
A
42 /** Basic set @stable ICU 3.4 */
43 ULOCDATA_ES_STANDARD=0,
44 /** Auxiliary set @stable ICU 3.4 */
45 ULOCDATA_ES_AUXILIARY=1,
46 /** Index Character set @stable ICU 4.8 */
47 ULOCDATA_ES_INDEX=2,
48 /** One higher than the last valid type @stable ICU 3.4 */
49 ULOCDATA_ES_COUNT=3
73c04bcf
A
50} ULocaleDataExemplarSetType;
51
52/** The possible types of delimiters.
46f4442e 53 * @stable ICU 3.4
73c04bcf
A
54 */
55typedef enum ULocaleDataDelimiterType {
4388f060
A
56 /** Quotation start @stable ICU 3.4 */
57 ULOCDATA_QUOTATION_START = 0,
58 /** Quotation end @stable ICU 3.4 */
59 ULOCDATA_QUOTATION_END = 1,
60 /** Alternate quotation start @stable ICU 3.4 */
61 ULOCDATA_ALT_QUOTATION_START = 2,
62 /** Alternate quotation end @stable ICU 3.4 */
63 ULOCDATA_ALT_QUOTATION_END = 3,
64 /** One higher than the last valid type @stable ICU 3.4 */
65 ULOCDATA_DELIMITER_COUNT = 4
73c04bcf
A
66} ULocaleDataDelimiterType;
67
68/**
69 * Opens a locale data object for the given locale
70 *
71 * @param localeID Specifies the locale associated with this locale
72 * data object.
73 * @param status Pointer to error status code.
46f4442e 74 * @stable ICU 3.4
73c04bcf 75 */
729e4ab9 76U_STABLE ULocaleData* U_EXPORT2
73c04bcf
A
77ulocdata_open(const char *localeID, UErrorCode *status);
78
79/**
80 * Closes a locale data object.
81 *
82 * @param uld The locale data object to close
46f4442e 83 * @stable ICU 3.4
73c04bcf 84 */
729e4ab9 85U_STABLE void U_EXPORT2
73c04bcf
A
86ulocdata_close(ULocaleData *uld);
87
729e4ab9
A
88#if U_SHOW_CPLUSPLUS_API
89
90U_NAMESPACE_BEGIN
91
92/**
93 * \class LocalULocaleDataPointer
94 * "Smart pointer" class, closes a ULocaleData via ulocdata_close().
95 * For most methods see the LocalPointerBase base class.
96 *
97 * @see LocalPointerBase
98 * @see LocalPointer
99 * @stable ICU 4.4
100 */
101U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDataPointer, ULocaleData, ulocdata_close);
102
103U_NAMESPACE_END
104
105#endif
106
73c04bcf
A
107/**
108 * Sets the "no Substitute" attribute of the locale data
109 * object. If true, then any methods associated with the
110 * locale data object will return null when there is no
111 * data available for that method, given the locale ID
112 * supplied to ulocdata_open().
113 *
114 * @param uld The locale data object to set.
115 * @param setting Value of the "no substitute" attribute.
46f4442e 116 * @stable ICU 3.4
73c04bcf 117 */
729e4ab9 118U_STABLE void U_EXPORT2
73c04bcf
A
119ulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);
120
121/**
122 * Retrieves the current "no Substitute" value of the locale data
123 * object. If true, then any methods associated with the
124 * locale data object will return null when there is no
125 * data available for that method, given the locale ID
126 * supplied to ulocdata_open().
127 *
128 * @param uld Pointer to the The locale data object to set.
129 * @return UBool Value of the "no substitute" attribute.
46f4442e 130 * @stable ICU 3.4
73c04bcf 131 */
729e4ab9 132U_STABLE UBool U_EXPORT2
73c04bcf 133ulocdata_getNoSubstitute(ULocaleData *uld);
374ca955
A
134
135/**
136 * Returns the set of exemplar characters for a locale.
137 *
729e4ab9 138 * @param uld Pointer to the locale data object from which the
73c04bcf 139 * exemplar character set is to be retrieved.
729e4ab9 140 * @param fillIn Pointer to a USet object to receive the
374ca955
A
141 * exemplar character set for the given locale. Previous
142 * contents of fillIn are lost. <em>If fillIn is NULL,
143 * then a new USet is created and returned. The caller
144 * owns the result and must dispose of it by calling
145 * uset_close.</em>
374ca955
A
146 * @param options Bitmask for options to apply to the exemplar pattern.
147 * Specify zero to retrieve the exemplar set as it is
148 * defined in the locale data. Specify
149 * USET_CASE_INSENSITIVE to retrieve a case-folded
150 * exemplar set. See uset_applyPattern for a complete
151 * list of valid options. The USET_IGNORE_SPACE bit is
152 * always set, regardless of the value of 'options'.
73c04bcf 153 * @param extype Specifies the type of exemplar set to be retrieved.
374ca955 154 * @param status Pointer to an input-output error code value;
4388f060
A
155 * must not be NULL. Will be set to U_MISSING_RESOURCE_ERROR
156 * if the requested data is not available.
374ca955
A
157 * @return USet* Either fillIn, or if fillIn is NULL, a pointer to
158 * a newly-allocated USet that the user must close.
4388f060 159 * In case of error, NULL is returned.
46f4442e 160 * @stable ICU 3.4
374ca955 161 */
729e4ab9
A
162U_STABLE USet* U_EXPORT2
163ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
73c04bcf
A
164 uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status);
165
166/**
167 * Returns one of the delimiter strings associated with a locale.
168 *
729e4ab9 169 * @param uld Pointer to the locale data object from which the
73c04bcf
A
170 * delimiter string is to be retrieved.
171 * @param type the type of delimiter to be retrieved.
172 * @param result A pointer to a buffer to receive the result.
173 * @param resultLength The maximum size of result.
174 * @param status Pointer to an error code value
175 * @return int32_t The total buffer size needed; if greater than resultLength,
176 * the output was truncated.
46f4442e 177 * @stable ICU 3.4
73c04bcf 178 */
729e4ab9 179U_STABLE int32_t U_EXPORT2
73c04bcf 180ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type, UChar *result, int32_t resultLength, UErrorCode *status);
374ca955 181
374ca955
A
182/**
183 * Enumeration for representing the measurement systems.
73c04bcf 184 * @stable ICU 2.8
374ca955
A
185 */
186typedef enum UMeasurementSystem {
187 UMS_SI, /** Measurement system specified by SI otherwise known as Metric system. */
729e4ab9 188 UMS_US, /** Measurement system followed in the United States of America. */
374ca955
A
189 UMS_LIMIT
190} UMeasurementSystem;
374ca955
A
191
192/**
193 * Returns the measurement system used in the locale specified by the localeID.
73c04bcf 194 * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
374ca955
A
195 *
196 * @param localeID The id of the locale for which the measurement system to be retrieved.
197 * @param status Must be a valid pointer to an error code value,
198 * which must not indicate a failure before the function call.
199 * @return UMeasurementSystem the measurement system used in the locale.
73c04bcf 200 * @stable ICU 2.8
374ca955 201 */
73c04bcf 202U_STABLE UMeasurementSystem U_EXPORT2
374ca955
A
203ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);
204
205/**
729e4ab9 206 * Returns the element gives the normal business letter size, and customary units.
374ca955
A
207 * The units for the numbers are always in <em>milli-meters</em>.
208 * For US since 8.5 and 11 do not yeild an integral value when converted to milli-meters,
209 * the values are rounded off.
729e4ab9 210 * So for A4 size paper the height and width are 297 mm and 210 mm repectively,
374ca955 211 * and for US letter size the height and width are 279 mm and 216 mm respectively.
73c04bcf 212 * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
374ca955
A
213 *
214 * @param localeID The id of the locale for which the paper size information to be retrieved.
215 * @param height A pointer to int to recieve the height information.
216 * @param width A pointer to int to recieve the width information.
217 * @param status Must be a valid pointer to an error code value,
218 * which must not indicate a failure before the function call.
73c04bcf 219 * @stable ICU 2.8
374ca955 220 */
73c04bcf 221U_STABLE void U_EXPORT2
374ca955
A
222ulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UErrorCode *status);
223
729e4ab9
A
224/**
225 * Return the current CLDR version used by the library.
226 * @param versionArray fillin that will recieve the version number
227 * @param status error code - could be U_MISSING_RESOURCE_ERROR if the version was not found.
228 * @stable ICU 4.2
229 */
230U_STABLE void U_EXPORT2
231ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status);
232
233/**
234 * Returns locale display pattern associated with a locale.
235 *
236 * @param uld Pointer to the locale data object from which the
237 * exemplar character set is to be retrieved.
238 * @param pattern locale display pattern for locale.
239 * @param patternCapacity the size of the buffer to store the locale display
240 * pattern with.
241 * @param status Must be a valid pointer to an error code value,
242 * which must not indicate a failure before the function call.
243 * @return the actual buffer size needed for localeDisplayPattern. If it's greater
244 * than patternCapacity, the returned pattern will be truncated.
245 *
246 * @stable ICU 4.2
247 */
248U_STABLE int32_t U_EXPORT2
249ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
250 UChar *pattern,
251 int32_t patternCapacity,
252 UErrorCode *status);
253
254
255/**
256 * Returns locale separator associated with a locale.
257 *
258 * @param uld Pointer to the locale data object from which the
259 * exemplar character set is to be retrieved.
260 * @param separator locale separator for locale.
261 * @param separatorCapacity the size of the buffer to store the locale
262 * separator with.
263 * @param status Must be a valid pointer to an error code value,
264 * which must not indicate a failure before the function call.
265 * @return the actual buffer size needed for localeSeparator. If it's greater
266 * than separatorCapacity, the returned separator will be truncated.
267 *
268 * @stable ICU 4.2
269 */
270U_STABLE int32_t U_EXPORT2
271ulocdata_getLocaleSeparator(ULocaleData *uld,
272 UChar *separator,
273 int32_t separatorCapacity,
274 UErrorCode *status);
374ca955 275#endif