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