ulocdata.h 11 KB

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