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