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