1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
6 * Copyright (C) 2003-2015, International Business Machines *
7 * Corporation and others. All Rights Reserved. *
9 ******************************************************************************
10 * file name: ulocdata.h
12 * tab size: 8 (not used)
15 * created on: 2003Oct21
16 * created by: Ram Viswanadha
19 #ifndef __ULOCDATA_H__
20 #define __ULOCDATA_H__
22 #include "unicode/ures.h"
23 #include "unicode/uloc.h"
24 #include "unicode/uset.h"
25 #include "unicode/localpointer.h"
29 * \brief C API: Provides access to locale data.
32 /** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */
35 /** A locale data object. @stable ICU 3.6 */
36 typedef struct ULocaleData ULocaleData
;
40 /** The possible types of exemplar character sets.
43 typedef enum ULocaleDataExemplarSetType
{
44 /** Basic set @stable ICU 3.4 */
45 ULOCDATA_ES_STANDARD
=0,
46 /** Auxiliary set @stable ICU 3.4 */
47 ULOCDATA_ES_AUXILIARY
=1,
48 /** Index Character set @stable ICU 4.8 */
50 /** Punctuation set @stable ICU 51 */
51 ULOCDATA_ES_PUNCTUATION
=3,
52 #ifndef U_HIDE_DEPRECATED_API
54 * One more than the highest normal ULocaleDataExemplarSetType value.
55 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
58 #endif /* U_HIDE_DEPRECATED_API */
59 } ULocaleDataExemplarSetType
;
61 /** The possible types of delimiters.
64 typedef enum ULocaleDataDelimiterType
{
65 /** Quotation start @stable ICU 3.4 */
66 ULOCDATA_QUOTATION_START
= 0,
67 /** Quotation end @stable ICU 3.4 */
68 ULOCDATA_QUOTATION_END
= 1,
69 /** Alternate quotation start @stable ICU 3.4 */
70 ULOCDATA_ALT_QUOTATION_START
= 2,
71 /** Alternate quotation end @stable ICU 3.4 */
72 ULOCDATA_ALT_QUOTATION_END
= 3,
73 #ifndef U_HIDE_DEPRECATED_API
75 * One more than the highest normal ULocaleDataDelimiterType value.
76 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
78 ULOCDATA_DELIMITER_COUNT
= 4
79 #endif /* U_HIDE_DEPRECATED_API */
80 } ULocaleDataDelimiterType
;
83 * Opens a locale data object for the given locale
85 * @param localeID Specifies the locale associated with this locale
87 * @param status Pointer to error status code.
90 U_STABLE ULocaleData
* U_EXPORT2
91 ulocdata_open(const char *localeID
, UErrorCode
*status
);
94 * Closes a locale data object.
96 * @param uld The locale data object to close
99 U_STABLE
void U_EXPORT2
100 ulocdata_close(ULocaleData
*uld
);
102 #if U_SHOW_CPLUSPLUS_API
107 * \class LocalULocaleDataPointer
108 * "Smart pointer" class, closes a ULocaleData via ulocdata_close().
109 * For most methods see the LocalPointerBase base class.
111 * @see LocalPointerBase
115 U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDataPointer
, ULocaleData
, ulocdata_close
);
122 * Sets the "no Substitute" attribute 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().
128 * @param uld The locale data object to set.
129 * @param setting Value of the "no substitute" attribute.
132 U_STABLE
void U_EXPORT2
133 ulocdata_setNoSubstitute(ULocaleData
*uld
, UBool setting
);
136 * Retrieves the current "no Substitute" value of the locale data
137 * object. If true, then any methods associated with the
138 * locale data object will return null when there is no
139 * data available for that method, given the locale ID
140 * supplied to ulocdata_open().
142 * @param uld Pointer to the The locale data object to set.
143 * @return UBool Value of the "no substitute" attribute.
146 U_STABLE UBool U_EXPORT2
147 ulocdata_getNoSubstitute(ULocaleData
*uld
);
150 * Returns the set of exemplar characters for a locale.
152 * @param uld Pointer to the locale data object from which the
153 * exemplar character set is to be retrieved.
154 * @param fillIn Pointer to a USet object to receive the
155 * exemplar character set for the given locale. Previous
156 * contents of fillIn are lost. <em>If fillIn is NULL,
157 * then a new USet is created and returned. The caller
158 * owns the result and must dispose of it by calling
160 * @param options Bitmask for options to apply to the exemplar pattern.
161 * Specify zero to retrieve the exemplar set as it is
162 * defined in the locale data. Specify
163 * USET_CASE_INSENSITIVE to retrieve a case-folded
164 * exemplar set. See uset_applyPattern for a complete
165 * list of valid options. The USET_IGNORE_SPACE bit is
166 * always set, regardless of the value of 'options'.
167 * @param extype Specifies the type of exemplar set to be retrieved.
168 * @param status Pointer to an input-output error code value;
169 * must not be NULL. Will be set to U_MISSING_RESOURCE_ERROR
170 * if the requested data is not available.
171 * @return USet* Either fillIn, or if fillIn is NULL, a pointer to
172 * a newly-allocated USet that the user must close.
173 * In case of error, NULL is returned.
176 U_STABLE USet
* U_EXPORT2
177 ulocdata_getExemplarSet(ULocaleData
*uld
, USet
*fillIn
,
178 uint32_t options
, ULocaleDataExemplarSetType extype
, UErrorCode
*status
);
181 * Returns one of the delimiter strings associated with a locale.
183 * @param uld Pointer to the locale data object from which the
184 * delimiter string is to be retrieved.
185 * @param type the type of delimiter to be retrieved.
186 * @param result A pointer to a buffer to receive the result.
187 * @param resultLength The maximum size of result.
188 * @param status Pointer to an error code value
189 * @return int32_t The total buffer size needed; if greater than resultLength,
190 * the output was truncated.
193 U_STABLE
int32_t U_EXPORT2
194 ulocdata_getDelimiter(ULocaleData
*uld
, ULocaleDataDelimiterType type
, UChar
*result
, int32_t resultLength
, UErrorCode
*status
);
197 * Enumeration for representing the measurement systems.
200 typedef enum UMeasurementSystem
{
201 UMS_SI
, /**< Measurement system specified by SI otherwise known as Metric system. @stable ICU 2.8 */
202 UMS_US
, /**< Measurement system followed in the United States of America. @stable ICU 2.8 */
203 UMS_UK
, /**< Mix of metric and imperial units used in Great Britain. @stable ICU 55 */
204 #ifndef U_HIDE_DEPRECATED_API
206 * One more than the highest normal UMeasurementSystem value.
207 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
210 #endif /* U_HIDE_DEPRECATED_API */
211 } UMeasurementSystem
;
214 * Returns the measurement system used in the locale specified by the localeID.
215 * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
217 * @param localeID The id of the locale for which the measurement system to be retrieved.
218 * @param status Must be a valid pointer to an error code value,
219 * which must not indicate a failure before the function call.
220 * @return UMeasurementSystem the measurement system used in the locale.
223 U_STABLE UMeasurementSystem U_EXPORT2
224 ulocdata_getMeasurementSystem(const char *localeID
, UErrorCode
*status
);
227 * Returns the element gives the normal business letter size, and customary units.
228 * The units for the numbers are always in <em>milli-meters</em>.
229 * For US since 8.5 and 11 do not yeild an integral value when converted to milli-meters,
230 * the values are rounded off.
231 * So for A4 size paper the height and width are 297 mm and 210 mm repectively,
232 * and for US letter size the height and width are 279 mm and 216 mm respectively.
233 * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
235 * @param localeID The id of the locale for which the paper size information to be retrieved.
236 * @param height A pointer to int to recieve the height information.
237 * @param width A pointer to int to recieve the width information.
238 * @param status Must be a valid pointer to an error code value,
239 * which must not indicate a failure before the function call.
242 U_STABLE
void U_EXPORT2
243 ulocdata_getPaperSize(const char *localeID
, int32_t *height
, int32_t *width
, UErrorCode
*status
);
246 * Return the current CLDR version used by the library.
247 * @param versionArray fillin that will recieve the version number
248 * @param status error code - could be U_MISSING_RESOURCE_ERROR if the version was not found.
251 U_STABLE
void U_EXPORT2
252 ulocdata_getCLDRVersion(UVersionInfo versionArray
, UErrorCode
*status
);
255 * Returns locale display pattern associated with a locale.
257 * @param uld Pointer to the locale data object from which the
258 * exemplar character set is to be retrieved.
259 * @param pattern locale display pattern for locale.
260 * @param patternCapacity the size of the buffer to store the locale display
262 * @param status Must be a valid pointer to an error code value,
263 * which must not indicate a failure before the function call.
264 * @return the actual buffer size needed for localeDisplayPattern. If it's greater
265 * than patternCapacity, the returned pattern will be truncated.
269 U_STABLE
int32_t U_EXPORT2
270 ulocdata_getLocaleDisplayPattern(ULocaleData
*uld
,
272 int32_t patternCapacity
,
277 * Returns locale separator associated with a locale.
279 * @param uld Pointer to the locale data object from which the
280 * exemplar character set is to be retrieved.
281 * @param separator locale separator for locale.
282 * @param separatorCapacity the size of the buffer to store the locale
284 * @param status Must be a valid pointer to an error code value,
285 * which must not indicate a failure before the function call.
286 * @return the actual buffer size needed for localeSeparator. If it's greater
287 * than separatorCapacity, the returned separator will be truncated.
291 U_STABLE
int32_t U_EXPORT2
292 ulocdata_getLocaleSeparator(ULocaleData
*uld
,
294 int32_t separatorCapacity
,