ulocdata.h 11 KB

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