• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 ******************************************************************************
3 *                                                                            *
4 * Copyright (C) 2003-2007, International Business Machines                   *
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"
23 
24 /**
25  * \file
26  * \brief C API: Provides access to locale data.
27  */
28 
29 /** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */
30 struct ULocaleData;
31 
32 /** A locale data object. @stable ICU 3.6 */
33 typedef struct ULocaleData ULocaleData;
34 
35 
36 
37 /** The possible types of exemplar character sets.
38   * @stable ICU 3.4
39   */
40 typedef enum ULocaleDataExemplarSetType  {
41      ULOCDATA_ES_STANDARD=0,      /* Basic set */
42      ULOCDATA_ES_AUXILIARY=1,     /* Auxiliary set */
43      ULOCDATA_ES_COUNT=2
44 } ULocaleDataExemplarSetType;
45 
46 /** The possible types of delimiters.
47   * @stable ICU 3.4
48   */
49 typedef enum ULocaleDataDelimiterType {
50 #ifndef U_HIDE_DRAFT_API
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 */
55 #endif
56      ULOCDATA_DELIMITER_COUNT = 4
57 } ULocaleDataDelimiterType;
58 
59 /**
60  * Opens a locale data object for the given locale
61  *
62  * @param localeID  Specifies the locale associated with this locale
63  *                  data object.
64  * @param status    Pointer to error status code.
65  * @stable ICU 3.4
66  */
67 U_STABLE ULocaleData* U_EXPORT2
68 ulocdata_open(const char *localeID, UErrorCode *status);
69 
70 /**
71  * Closes a locale data object.
72  *
73  * @param uld       The locale data object to close
74  * @stable ICU 3.4
75  */
76 U_STABLE void U_EXPORT2
77 ulocdata_close(ULocaleData *uld);
78 
79 /**
80  * Sets the "no Substitute" attribute of the locale data
81  * object.  If true, then any methods associated with the
82  * locale data object will return null when there is no
83  * data available for that method, given the locale ID
84  * supplied to ulocdata_open().
85  *
86  * @param uld       The locale data object to set.
87  * @param setting   Value of the "no substitute" attribute.
88  * @stable ICU 3.4
89  */
90 U_STABLE void U_EXPORT2
91 ulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);
92 
93 /**
94  * Retrieves the current "no Substitute" value of the locale data
95  * object.  If true, then any methods associated with the
96  * locale data object will return null when there is no
97  * data available for that method, given the locale ID
98  * supplied to ulocdata_open().
99  *
100  * @param uld       Pointer to the The locale data object to set.
101  * @return UBool    Value of the "no substitute" attribute.
102  * @stable ICU 3.4
103  */
104 U_STABLE UBool U_EXPORT2
105 ulocdata_getNoSubstitute(ULocaleData *uld);
106 
107 /**
108  * Returns the set of exemplar characters for a locale.
109  *
110  * @param uld       Pointer to the locale data object from which the
111  *                  exemplar character set is to be retrieved.
112  * @param fillIn    Pointer to a USet object to receive the
113  *                  exemplar character set for the given locale.  Previous
114  *                  contents of fillIn are lost.  <em>If fillIn is NULL,
115  *                  then a new USet is created and returned.  The caller
116  *                  owns the result and must dispose of it by calling
117  *                  uset_close.</em>
118  * @param options   Bitmask for options to apply to the exemplar pattern.
119  *                  Specify zero to retrieve the exemplar set as it is
120  *                  defined in the locale data.  Specify
121  *                  USET_CASE_INSENSITIVE to retrieve a case-folded
122  *                  exemplar set.  See uset_applyPattern for a complete
123  *                  list of valid options.  The USET_IGNORE_SPACE bit is
124  *                  always set, regardless of the value of 'options'.
125  * @param extype    Specifies the type of exemplar set to be retrieved.
126  * @param status    Pointer to an input-output error code value;
127  *                  must not be NULL.
128  * @return USet*    Either fillIn, or if fillIn is NULL, a pointer to
129  *                  a newly-allocated USet that the user must close.
130  * @stable ICU 3.4
131  */
132 U_STABLE USet* U_EXPORT2
133 ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
134                         uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status);
135 
136 /**
137  * Returns one of the delimiter strings associated with a locale.
138  *
139  * @param uld           Pointer to the locale data object from which the
140  *                      delimiter string is to be retrieved.
141  * @param type          the type of delimiter to be retrieved.
142  * @param result        A pointer to a buffer to receive the result.
143  * @param resultLength  The maximum size of result.
144  * @param status        Pointer to an error code value
145  * @return int32_t      The total buffer size needed; if greater than resultLength,
146  *                      the output was truncated.
147  * @stable ICU 3.4
148  */
149 U_STABLE int32_t U_EXPORT2
150 ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type, UChar *result, int32_t resultLength, UErrorCode *status);
151 
152 /**
153  * Enumeration for representing the measurement systems.
154  * @stable ICU 2.8
155  */
156 typedef enum UMeasurementSystem {
157     UMS_SI,     /** Measurement system specified by SI otherwise known as Metric system. */
158     UMS_US,     /** Measurement system followed in the United States of America. */
159     UMS_LIMIT
160 } UMeasurementSystem;
161 
162 /**
163  * Returns the measurement system used in the locale specified by the localeID.
164  * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
165  *
166  * @param localeID      The id of the locale for which the measurement system to be retrieved.
167  * @param status        Must be a valid pointer to an error code value,
168  *                      which must not indicate a failure before the function call.
169  * @return UMeasurementSystem the measurement system used in the locale.
170  * @stable ICU 2.8
171  */
172 U_STABLE UMeasurementSystem U_EXPORT2
173 ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);
174 
175 /**
176  * Returns the element gives the normal business letter size, and customary units.
177  * The units for the numbers are always in <em>milli-meters</em>.
178  * For US since 8.5 and 11 do not yeild an integral value when converted to milli-meters,
179  * the values are rounded off.
180  * So for A4 size paper the height and width are 297 mm and 210 mm repectively,
181  * and for US letter size the height and width are 279 mm and 216 mm respectively.
182  * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
183  *
184  * @param localeID      The id of the locale for which the paper size information to be retrieved.
185  * @param height        A pointer to int to recieve the height information.
186  * @param width         A pointer to int to recieve the width information.
187  * @param status        Must be a valid pointer to an error code value,
188  *                      which must not indicate a failure before the function call.
189  * @stable ICU 2.8
190  */
191 U_STABLE void U_EXPORT2
192 ulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UErrorCode *status);
193 
194 #endif
195