ulocdata.h 11 KB

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