michael@0: /*
michael@0: ******************************************************************************
michael@0: * *
michael@0: * Copyright (C) 2003-2013, International Business Machines *
michael@0: * Corporation and others. All Rights Reserved. *
michael@0: * *
michael@0: ******************************************************************************
michael@0: * file name: ulocdata.h
michael@0: * encoding: US-ASCII
michael@0: * tab size: 8 (not used)
michael@0: * indentation:4
michael@0: *
michael@0: * created on: 2003Oct21
michael@0: * created by: Ram Viswanadha
michael@0: */
michael@0:
michael@0: #ifndef __ULOCDATA_H__
michael@0: #define __ULOCDATA_H__
michael@0:
michael@0: #include "unicode/ures.h"
michael@0: #include "unicode/uloc.h"
michael@0: #include "unicode/uset.h"
michael@0: #include "unicode/localpointer.h"
michael@0:
michael@0: /**
michael@0: * \file
michael@0: * \brief C API: Provides access to locale data.
michael@0: */
michael@0:
michael@0: /** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */
michael@0: struct ULocaleData;
michael@0:
michael@0: /** A locale data object. @stable ICU 3.6 */
michael@0: typedef struct ULocaleData ULocaleData;
michael@0:
michael@0:
michael@0:
michael@0: /** The possible types of exemplar character sets.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: typedef enum ULocaleDataExemplarSetType {
michael@0: /** Basic set @stable ICU 3.4 */
michael@0: ULOCDATA_ES_STANDARD=0,
michael@0: /** Auxiliary set @stable ICU 3.4 */
michael@0: ULOCDATA_ES_AUXILIARY=1,
michael@0: /** Index Character set @stable ICU 4.8 */
michael@0: ULOCDATA_ES_INDEX=2,
michael@0: #ifndef U_HIDE_DRAFT_API
michael@0: /** Punctuation set @draft ICU 51 */
michael@0: ULOCDATA_ES_PUNCTUATION=3,
michael@0: #endif /* U_HIDE_DRAFT_API */
michael@0: /** One higher than the last valid type @stable ICU 3.4 */
michael@0: ULOCDATA_ES_COUNT=4
michael@0: } ULocaleDataExemplarSetType;
michael@0:
michael@0: /** The possible types of delimiters.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: typedef enum ULocaleDataDelimiterType {
michael@0: /** Quotation start @stable ICU 3.4 */
michael@0: ULOCDATA_QUOTATION_START = 0,
michael@0: /** Quotation end @stable ICU 3.4 */
michael@0: ULOCDATA_QUOTATION_END = 1,
michael@0: /** Alternate quotation start @stable ICU 3.4 */
michael@0: ULOCDATA_ALT_QUOTATION_START = 2,
michael@0: /** Alternate quotation end @stable ICU 3.4 */
michael@0: ULOCDATA_ALT_QUOTATION_END = 3,
michael@0: /** One higher than the last valid type @stable ICU 3.4 */
michael@0: ULOCDATA_DELIMITER_COUNT = 4
michael@0: } ULocaleDataDelimiterType;
michael@0:
michael@0: /**
michael@0: * Opens a locale data object for the given locale
michael@0: *
michael@0: * @param localeID Specifies the locale associated with this locale
michael@0: * data object.
michael@0: * @param status Pointer to error status code.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: U_STABLE ULocaleData* U_EXPORT2
michael@0: ulocdata_open(const char *localeID, UErrorCode *status);
michael@0:
michael@0: /**
michael@0: * Closes a locale data object.
michael@0: *
michael@0: * @param uld The locale data object to close
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: U_STABLE void U_EXPORT2
michael@0: ulocdata_close(ULocaleData *uld);
michael@0:
michael@0: #if U_SHOW_CPLUSPLUS_API
michael@0:
michael@0: U_NAMESPACE_BEGIN
michael@0:
michael@0: /**
michael@0: * \class LocalULocaleDataPointer
michael@0: * "Smart pointer" class, closes a ULocaleData via ulocdata_close().
michael@0: * For most methods see the LocalPointerBase base class.
michael@0: *
michael@0: * @see LocalPointerBase
michael@0: * @see LocalPointer
michael@0: * @stable ICU 4.4
michael@0: */
michael@0: U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDataPointer, ULocaleData, ulocdata_close);
michael@0:
michael@0: U_NAMESPACE_END
michael@0:
michael@0: #endif
michael@0:
michael@0: /**
michael@0: * Sets the "no Substitute" attribute of the locale data
michael@0: * object. If true, then any methods associated with the
michael@0: * locale data object will return null when there is no
michael@0: * data available for that method, given the locale ID
michael@0: * supplied to ulocdata_open().
michael@0: *
michael@0: * @param uld The locale data object to set.
michael@0: * @param setting Value of the "no substitute" attribute.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: U_STABLE void U_EXPORT2
michael@0: ulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);
michael@0:
michael@0: /**
michael@0: * Retrieves the current "no Substitute" value of the locale data
michael@0: * object. If true, then any methods associated with the
michael@0: * locale data object will return null when there is no
michael@0: * data available for that method, given the locale ID
michael@0: * supplied to ulocdata_open().
michael@0: *
michael@0: * @param uld Pointer to the The locale data object to set.
michael@0: * @return UBool Value of the "no substitute" attribute.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: U_STABLE UBool U_EXPORT2
michael@0: ulocdata_getNoSubstitute(ULocaleData *uld);
michael@0:
michael@0: /**
michael@0: * Returns the set of exemplar characters for a locale.
michael@0: *
michael@0: * @param uld Pointer to the locale data object from which the
michael@0: * exemplar character set is to be retrieved.
michael@0: * @param fillIn Pointer to a USet object to receive the
michael@0: * exemplar character set for the given locale. Previous
michael@0: * contents of fillIn are lost. If fillIn is NULL,
michael@0: * then a new USet is created and returned. The caller
michael@0: * owns the result and must dispose of it by calling
michael@0: * uset_close.
michael@0: * @param options Bitmask for options to apply to the exemplar pattern.
michael@0: * Specify zero to retrieve the exemplar set as it is
michael@0: * defined in the locale data. Specify
michael@0: * USET_CASE_INSENSITIVE to retrieve a case-folded
michael@0: * exemplar set. See uset_applyPattern for a complete
michael@0: * list of valid options. The USET_IGNORE_SPACE bit is
michael@0: * always set, regardless of the value of 'options'.
michael@0: * @param extype Specifies the type of exemplar set to be retrieved.
michael@0: * @param status Pointer to an input-output error code value;
michael@0: * must not be NULL. Will be set to U_MISSING_RESOURCE_ERROR
michael@0: * if the requested data is not available.
michael@0: * @return USet* Either fillIn, or if fillIn is NULL, a pointer to
michael@0: * a newly-allocated USet that the user must close.
michael@0: * In case of error, NULL is returned.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: U_STABLE USet* U_EXPORT2
michael@0: ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,
michael@0: uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status);
michael@0:
michael@0: /**
michael@0: * Returns one of the delimiter strings associated with a locale.
michael@0: *
michael@0: * @param uld Pointer to the locale data object from which the
michael@0: * delimiter string is to be retrieved.
michael@0: * @param type the type of delimiter to be retrieved.
michael@0: * @param result A pointer to a buffer to receive the result.
michael@0: * @param resultLength The maximum size of result.
michael@0: * @param status Pointer to an error code value
michael@0: * @return int32_t The total buffer size needed; if greater than resultLength,
michael@0: * the output was truncated.
michael@0: * @stable ICU 3.4
michael@0: */
michael@0: U_STABLE int32_t U_EXPORT2
michael@0: ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type, UChar *result, int32_t resultLength, UErrorCode *status);
michael@0:
michael@0: /**
michael@0: * Enumeration for representing the measurement systems.
michael@0: * @stable ICU 2.8
michael@0: */
michael@0: typedef enum UMeasurementSystem {
michael@0: UMS_SI, /** Measurement system specified by SI otherwise known as Metric system. */
michael@0: UMS_US, /** Measurement system followed in the United States of America. */
michael@0: UMS_LIMIT
michael@0: } UMeasurementSystem;
michael@0:
michael@0: /**
michael@0: * Returns the measurement system used in the locale specified by the localeID.
michael@0: * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
michael@0: *
michael@0: * @param localeID The id of the locale for which the measurement system to be retrieved.
michael@0: * @param status Must be a valid pointer to an error code value,
michael@0: * which must not indicate a failure before the function call.
michael@0: * @return UMeasurementSystem the measurement system used in the locale.
michael@0: * @stable ICU 2.8
michael@0: */
michael@0: U_STABLE UMeasurementSystem U_EXPORT2
michael@0: ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);
michael@0:
michael@0: /**
michael@0: * Returns the element gives the normal business letter size, and customary units.
michael@0: * The units for the numbers are always in milli-meters.
michael@0: * For US since 8.5 and 11 do not yeild an integral value when converted to milli-meters,
michael@0: * the values are rounded off.
michael@0: * So for A4 size paper the height and width are 297 mm and 210 mm repectively,
michael@0: * and for US letter size the height and width are 279 mm and 216 mm respectively.
michael@0: * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
michael@0: *
michael@0: * @param localeID The id of the locale for which the paper size information to be retrieved.
michael@0: * @param height A pointer to int to recieve the height information.
michael@0: * @param width A pointer to int to recieve the width information.
michael@0: * @param status Must be a valid pointer to an error code value,
michael@0: * which must not indicate a failure before the function call.
michael@0: * @stable ICU 2.8
michael@0: */
michael@0: U_STABLE void U_EXPORT2
michael@0: ulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UErrorCode *status);
michael@0:
michael@0: /**
michael@0: * Return the current CLDR version used by the library.
michael@0: * @param versionArray fillin that will recieve the version number
michael@0: * @param status error code - could be U_MISSING_RESOURCE_ERROR if the version was not found.
michael@0: * @stable ICU 4.2
michael@0: */
michael@0: U_STABLE void U_EXPORT2
michael@0: ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status);
michael@0:
michael@0: /**
michael@0: * Returns locale display pattern associated with a locale.
michael@0: *
michael@0: * @param uld Pointer to the locale data object from which the
michael@0: * exemplar character set is to be retrieved.
michael@0: * @param pattern locale display pattern for locale.
michael@0: * @param patternCapacity the size of the buffer to store the locale display
michael@0: * pattern with.
michael@0: * @param status Must be a valid pointer to an error code value,
michael@0: * which must not indicate a failure before the function call.
michael@0: * @return the actual buffer size needed for localeDisplayPattern. If it's greater
michael@0: * than patternCapacity, the returned pattern will be truncated.
michael@0: *
michael@0: * @stable ICU 4.2
michael@0: */
michael@0: U_STABLE int32_t U_EXPORT2
michael@0: ulocdata_getLocaleDisplayPattern(ULocaleData *uld,
michael@0: UChar *pattern,
michael@0: int32_t patternCapacity,
michael@0: UErrorCode *status);
michael@0:
michael@0:
michael@0: /**
michael@0: * Returns locale separator associated with a locale.
michael@0: *
michael@0: * @param uld Pointer to the locale data object from which the
michael@0: * exemplar character set is to be retrieved.
michael@0: * @param separator locale separator for locale.
michael@0: * @param separatorCapacity the size of the buffer to store the locale
michael@0: * separator with.
michael@0: * @param status Must be a valid pointer to an error code value,
michael@0: * which must not indicate a failure before the function call.
michael@0: * @return the actual buffer size needed for localeSeparator. If it's greater
michael@0: * than separatorCapacity, the returned separator will be truncated.
michael@0: *
michael@0: * @stable ICU 4.2
michael@0: */
michael@0: U_STABLE int32_t U_EXPORT2
michael@0: ulocdata_getLocaleSeparator(ULocaleData *uld,
michael@0: UChar *separator,
michael@0: int32_t separatorCapacity,
michael@0: UErrorCode *status);
michael@0: #endif