jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ********************************************************************** jpayne@69: * Copyright (C) 1997-2016, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: ********************************************************************** jpayne@69: * jpayne@69: * File ULOC.H jpayne@69: * jpayne@69: * Modification History: jpayne@69: * jpayne@69: * Date Name Description jpayne@69: * 04/01/97 aliu Creation. jpayne@69: * 08/22/98 stephen JDK 1.2 sync. jpayne@69: * 12/08/98 rtg New C API for Locale jpayne@69: * 03/30/99 damiba overhaul jpayne@69: * 03/31/99 helena Javadoc for uloc functions. jpayne@69: * 04/15/99 Madhu Updated Javadoc jpayne@69: ******************************************************************************** jpayne@69: */ jpayne@69: jpayne@69: #ifndef ULOC_H jpayne@69: #define ULOC_H jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: #include "unicode/uenum.h" jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: Locale jpayne@69: * jpayne@69: *
Locale
represents a specific geographical, political,
jpayne@69: * or cultural region. An operation that requires a Locale
to perform
jpayne@69: * its task is called locale-sensitive and uses the Locale
jpayne@69: * to tailor information for the user. For example, displaying a number
jpayne@69: * is a locale-sensitive operation--the number should be formatted
jpayne@69: * according to the customs/conventions of the user's native country,
jpayne@69: * region, or culture. In the C APIs, a locales is simply a const char string.
jpayne@69: *
jpayne@69: *
jpayne@69: * You create a Locale
with one of the three options listed below.
jpayne@69: * Each of the component is separated by '_' in the locale string.
jpayne@69: * \htmlonly
\endhtmlonly jpayne@69: *\endhtmlonly jpayne@69: * The first option is a valid ISO jpayne@69: * Language Code. These codes are the lower-case two-letter jpayne@69: * codes as defined by ISO-639. jpayne@69: * You can find a full list of these codes at a number of sites, such as: jpayne@69: *jpayne@69: * \code jpayne@69: * newLanguage jpayne@69: * jpayne@69: * newLanguage + newCountry jpayne@69: * jpayne@69: * newLanguage + newCountry + newVariant jpayne@69: * \endcode jpayne@69: *jpayne@69: * \htmlonly
jpayne@69: * The second option includes an additional ISO Country
jpayne@69: * Code. These codes are the upper-case two-letter codes
jpayne@69: * as defined by ISO-3166.
jpayne@69: * You can find a full list of these codes at a number of sites, such as:
jpayne@69: *
jpayne@69: * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
jpayne@69: *
jpayne@69: *
jpayne@69: * The third option requires another additional information--the jpayne@69: * Variant. jpayne@69: * The Variant codes are vendor and browser-specific. jpayne@69: * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. jpayne@69: * Where there are two variants, separate them with an underscore, and jpayne@69: * put the most important one first. For jpayne@69: * example, a Traditional Spanish collation might be referenced, with jpayne@69: * "ES", "ES", "Traditional_WIN". jpayne@69: * jpayne@69: *
jpayne@69: * Because a Locale
is just an identifier for a region,
jpayne@69: * no validity check is performed when you specify a Locale
.
jpayne@69: * If you want to see whether particular resources are available for the
jpayne@69: * Locale
you asked for, you must query those resources. For
jpayne@69: * example, ask the UNumberFormat
for the locales it supports
jpayne@69: * using its getAvailable
method.
jpayne@69: *
Note: When you ask for a resource for a particular
jpayne@69: * locale, you get back the best available match, not necessarily
jpayne@69: * precisely what you asked for. For more information, look at
jpayne@69: * UResourceBundle
.
jpayne@69: *
jpayne@69: *
jpayne@69: * The Locale
provides a number of convenient constants
jpayne@69: * that you can use to specify the commonly used
jpayne@69: * locales. For example, the following refers to a locale
jpayne@69: * for the United States:
jpayne@69: * \htmlonly
\endhtmlonly jpayne@69: *\endhtmlonly jpayne@69: * jpayne@69: *jpayne@69: * \code jpayne@69: * ULOC_US jpayne@69: * \endcode jpayne@69: *jpayne@69: * \htmlonly
jpayne@69: * Once you've specified a locale you can query it for information about
jpayne@69: * itself. Use uloc_getCountry
to get the ISO Country Code and
jpayne@69: * uloc_getLanguage
to get the ISO Language Code. You can
jpayne@69: * use uloc_getDisplayCountry
to get the
jpayne@69: * name of the country suitable for displaying to the user. Similarly,
jpayne@69: * you can use uloc_getDisplayLanguage
to get the name of
jpayne@69: * the language suitable for displaying to the user. Interestingly,
jpayne@69: * the uloc_getDisplayXXX
methods are themselves locale-sensitive
jpayne@69: * and have two versions: one that uses the default locale and one
jpayne@69: * that takes a locale as an argument and displays the name or country in
jpayne@69: * a language appropriate to that locale.
jpayne@69: *
jpayne@69: *
jpayne@69: * The ICU provides a number of services that perform locale-sensitive
jpayne@69: * operations. For example, the unum_xxx
functions format
jpayne@69: * numbers, currency, or percentages in a locale-sensitive manner.
jpayne@69: *
\endhtmlonly jpayne@69: *\endhtmlonly jpayne@69: * Each of these methods has two variants; one with an explicit locale jpayne@69: * and one without; the latter using the default locale. jpayne@69: * \htmlonlyjpayne@69: * \code jpayne@69: * UErrorCode success = U_ZERO_ERROR; jpayne@69: * UNumberFormat *nf; jpayne@69: * const char* myLocale = "fr_FR"; jpayne@69: * jpayne@69: * nf = unum_open( UNUM_DEFAULT, NULL, success ); jpayne@69: * unum_close(nf); jpayne@69: * nf = unum_open( UNUM_CURRENCY, NULL, success ); jpayne@69: * unum_close(nf); jpayne@69: * nf = unum_open( UNUM_PERCENT, NULL, success ); jpayne@69: * unum_close(nf); jpayne@69: * \endcode jpayne@69: *jpayne@69: * \htmlonly
\endhtmlonly jpayne@69: *\endhtmlonly jpayne@69: * Ajpayne@69: * \code jpayne@69: * jpayne@69: * nf = unum_open( UNUM_DEFAULT, myLocale, success ); jpayne@69: * unum_close(nf); jpayne@69: * nf = unum_open( UNUM_CURRENCY, myLocale, success ); jpayne@69: * unum_close(nf); jpayne@69: * nf = unum_open( UNUM_PERCENT, myLocale, success ); jpayne@69: * unum_close(nf); jpayne@69: * \endcode jpayne@69: *jpayne@69: * \htmlonly
Locale
is the mechanism for identifying the kind of services
jpayne@69: * (UNumberFormat
) that you would like to get. The locale is
jpayne@69: * just a mechanism for identifying these services.
jpayne@69: *
jpayne@69: * jpayne@69: * Each international service that performs locale-sensitive operations jpayne@69: * allows you jpayne@69: * to get all the available objects of that type. You can sift jpayne@69: * through these objects by language, country, or variant, jpayne@69: * and use the display names to present a menu to the user. jpayne@69: * For example, you can create a menu of all the collation objects jpayne@69: * suitable for a given language. Such classes implement these jpayne@69: * three class methods: jpayne@69: * \htmlonly
\endhtmlonly jpayne@69: *\endhtmlonly jpayne@69: *jpayne@69: * \code jpayne@69: * const char* uloc_getAvailable(int32_t index); jpayne@69: * int32_t uloc_countAvailable(); jpayne@69: * int32_t jpayne@69: * uloc_getDisplayName(const char* localeID, jpayne@69: * const char* inLocaleID, jpayne@69: * UChar* result, jpayne@69: * int32_t maxResultSize, jpayne@69: * UErrorCode* err); jpayne@69: * jpayne@69: * \endcode jpayne@69: *jpayne@69: * \htmlonly
jpayne@69: * Concerning POSIX/RFC1766 Locale IDs, jpayne@69: * the getLanguage/getCountry/getVariant/getName functions do understand jpayne@69: * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT jpayne@69: * and if there is not an ICU-stype variant, uloc_getVariant() for example jpayne@69: * will return the one listed after the \@at sign. As well, the hyphen jpayne@69: * "-" is recognized as a country/variant separator similarly to RFC1766. jpayne@69: * So for example, "en-us" will be interpreted as en_US. jpayne@69: * As a result, uloc_getName() is far from a no-op, and will have the jpayne@69: * effect of converting POSIX/RFC1766 IDs into ICU form, although it does jpayne@69: * NOT map any of the actual codes (i.e. russian->ru) in any way. jpayne@69: * Applications should call uloc_getName() at the point where a locale ID jpayne@69: * is coming from an external source (user entry, OS, web browser) jpayne@69: * and pass the resulting string to other ICU functions. For example, jpayne@69: * don't use de-de\@EURO as an argument to resourcebundle. jpayne@69: * jpayne@69: * @see UResourceBundle jpayne@69: */ jpayne@69: jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_CHINESE "zh" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_ENGLISH "en" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_FRENCH "fr" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_GERMAN "de" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_ITALIAN "it" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_JAPANESE "ja" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_KOREAN "ko" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_SIMPLIFIED_CHINESE "zh_CN" jpayne@69: /** Useful constant for this language. @stable ICU 2.0 */ jpayne@69: #define ULOC_TRADITIONAL_CHINESE "zh_TW" jpayne@69: jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_CANADA "en_CA" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_CANADA_FRENCH "fr_CA" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_CHINA "zh_CN" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_PRC "zh_CN" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_FRANCE "fr_FR" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_GERMANY "de_DE" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_ITALY "it_IT" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_JAPAN "ja_JP" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_KOREA "ko_KR" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_TAIWAN "zh_TW" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_UK "en_GB" jpayne@69: /** Useful constant for this country/region. @stable ICU 2.0 */ jpayne@69: #define ULOC_US "en_US" jpayne@69: jpayne@69: /** jpayne@69: * Useful constant for the maximum size of the language part of a locale ID. jpayne@69: * (including the terminating NULL). jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: #define ULOC_LANG_CAPACITY 12 jpayne@69: jpayne@69: /** jpayne@69: * Useful constant for the maximum size of the country part of a locale ID jpayne@69: * (including the terminating NULL). jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: #define ULOC_COUNTRY_CAPACITY 4 jpayne@69: /** jpayne@69: * Useful constant for the maximum size of the whole locale ID jpayne@69: * (including the terminating NULL and all keywords). jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: #define ULOC_FULLNAME_CAPACITY 157 jpayne@69: jpayne@69: /** jpayne@69: * Useful constant for the maximum size of the script part of a locale ID jpayne@69: * (including the terminating NULL). jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: #define ULOC_SCRIPT_CAPACITY 6 jpayne@69: jpayne@69: /** jpayne@69: * Useful constant for the maximum size of keywords in a locale jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: #define ULOC_KEYWORDS_CAPACITY 96 jpayne@69: jpayne@69: /** jpayne@69: * Useful constant for the maximum total size of keywords and their values in a locale jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100 jpayne@69: jpayne@69: /** jpayne@69: * Invariant character separating keywords from the locale string jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_SEPARATOR '@' jpayne@69: jpayne@69: /** jpayne@69: * Unicode code point for '@' separating keywords from the locale string. jpayne@69: * @see ULOC_KEYWORD_SEPARATOR jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40 jpayne@69: jpayne@69: /** jpayne@69: * Invariant character for assigning value to a keyword jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_ASSIGN '=' jpayne@69: jpayne@69: /** jpayne@69: * Unicode code point for '=' for assigning value to a keyword. jpayne@69: * @see ULOC_KEYWORD_ASSIGN jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D jpayne@69: jpayne@69: /** jpayne@69: * Invariant character separating keywords jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_ITEM_SEPARATOR ';' jpayne@69: jpayne@69: /** jpayne@69: * Unicode code point for ';' separating keywords jpayne@69: * @see ULOC_KEYWORD_ITEM_SEPARATOR jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: #define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B jpayne@69: jpayne@69: /** jpayne@69: * Constants for *_getLocale() jpayne@69: * Allow user to select whether she wants information on jpayne@69: * requested, valid or actual locale. jpayne@69: * For example, a collator for "en_US_CALIFORNIA" was jpayne@69: * requested. In the current state of ICU (2.0), jpayne@69: * the requested locale is "en_US_CALIFORNIA", jpayne@69: * the valid locale is "en_US" (most specific locale supported by ICU) jpayne@69: * and the actual locale is "root" (the collation data comes unmodified jpayne@69: * from the UCA) jpayne@69: * The locale is considered supported by ICU if there is a core ICU bundle jpayne@69: * for that locale (although it may be empty). jpayne@69: * @stable ICU 2.1 jpayne@69: */ jpayne@69: typedef enum { jpayne@69: /** This is locale the data actually comes from jpayne@69: * @stable ICU 2.1 jpayne@69: */ jpayne@69: ULOC_ACTUAL_LOCALE = 0, jpayne@69: /** This is the most specific locale supported by ICU jpayne@69: * @stable ICU 2.1 jpayne@69: */ jpayne@69: ULOC_VALID_LOCALE = 1, jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** This is the requested locale jpayne@69: * @deprecated ICU 2.8 jpayne@69: */ jpayne@69: ULOC_REQUESTED_LOCALE = 2, jpayne@69: jpayne@69: /** jpayne@69: * One more than the highest normal ULocDataLocaleType value. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: ULOC_DATA_LOCALE_TYPE_LIMIT = 3 jpayne@69: #endif // U_HIDE_DEPRECATED_API jpayne@69: } ULocDataLocaleType; jpayne@69: jpayne@69: #ifndef U_HIDE_SYSTEM_API jpayne@69: /** jpayne@69: * Gets ICU's default locale. jpayne@69: * The returned string is a snapshot in time, and will remain valid jpayne@69: * and unchanged even when uloc_setDefault() is called. jpayne@69: * The returned storage is owned by ICU, and must not be altered or deleted jpayne@69: * by the caller. jpayne@69: * jpayne@69: * @return the ICU default locale jpayne@69: * @system jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE const char* U_EXPORT2 jpayne@69: uloc_getDefault(void); jpayne@69: jpayne@69: /** jpayne@69: * Sets ICU's default locale. jpayne@69: * By default (without calling this function), ICU's default locale will be based jpayne@69: * on information obtained from the underlying system environment. jpayne@69: *
jpayne@69: * Changes to ICU's default locale do not propagate back to the jpayne@69: * system environment. jpayne@69: *
jpayne@69: * Changes to ICU's default locale to not affect any ICU services that
jpayne@69: * may already be open based on the previous default locale value.
jpayne@69: *
jpayne@69: * @param localeID the new ICU default locale. A value of NULL will try to get
jpayne@69: * the system's default locale.
jpayne@69: * @param status the error information if the setting of default locale fails
jpayne@69: * @system
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE void U_EXPORT2
jpayne@69: uloc_setDefault(const char* localeID,
jpayne@69: UErrorCode* status);
jpayne@69: #endif /* U_HIDE_SYSTEM_API */
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the language code for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the ISO language code with
jpayne@69: * @param language the language code for localeID
jpayne@69: * @param languageCapacity the size of the language buffer to store the
jpayne@69: * language code with
jpayne@69: * @param err error information if retrieving the language code failed
jpayne@69: * @return the actual buffer size needed for the language code. If it's greater
jpayne@69: * than languageCapacity, the returned language code will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getLanguage(const char* localeID,
jpayne@69: char* language,
jpayne@69: int32_t languageCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the script code for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the ISO language code with
jpayne@69: * @param script the language code for localeID
jpayne@69: * @param scriptCapacity the size of the language buffer to store the
jpayne@69: * language code with
jpayne@69: * @param err error information if retrieving the language code failed
jpayne@69: * @return the actual buffer size needed for the language code. If it's greater
jpayne@69: * than scriptCapacity, the returned language code will be truncated.
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getScript(const char* localeID,
jpayne@69: char* script,
jpayne@69: int32_t scriptCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the country code for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the country code with
jpayne@69: * @param country the country code for localeID
jpayne@69: * @param countryCapacity the size of the country buffer to store the
jpayne@69: * country code with
jpayne@69: * @param err error information if retrieving the country code failed
jpayne@69: * @return the actual buffer size needed for the country code. If it's greater
jpayne@69: * than countryCapacity, the returned country code will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getCountry(const char* localeID,
jpayne@69: char* country,
jpayne@69: int32_t countryCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the variant code for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the variant code with
jpayne@69: * @param variant the variant code for localeID
jpayne@69: * @param variantCapacity the size of the variant buffer to store the
jpayne@69: * variant code with
jpayne@69: * @param err error information if retrieving the variant code failed
jpayne@69: * @return the actual buffer size needed for the variant code. If it's greater
jpayne@69: * than variantCapacity, the returned variant code will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getVariant(const char* localeID,
jpayne@69: char* variant,
jpayne@69: int32_t variantCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the full name for the specified locale.
jpayne@69: * Note: This has the effect of 'canonicalizing' the ICU locale ID to
jpayne@69: * a certain extent. Upper and lower case are set as needed.
jpayne@69: * It does NOT map aliased names in any way.
jpayne@69: * See the top of this header file.
jpayne@69: * This API supports preflighting.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the full name with
jpayne@69: * @param name fill in buffer for the name without keywords.
jpayne@69: * @param nameCapacity capacity of the fill in buffer.
jpayne@69: * @param err error information if retrieving the full name failed
jpayne@69: * @return the actual buffer size needed for the full name. If it's greater
jpayne@69: * than nameCapacity, the returned full name will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getName(const char* localeID,
jpayne@69: char* name,
jpayne@69: int32_t nameCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the full name for the specified locale.
jpayne@69: * Note: This has the effect of 'canonicalizing' the string to
jpayne@69: * a certain extent. Upper and lower case are set as needed,
jpayne@69: * and if the components were in 'POSIX' format they are changed to
jpayne@69: * ICU format. It does NOT map aliased names in any way.
jpayne@69: * See the top of this header file.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the full name with
jpayne@69: * @param name the full name for localeID
jpayne@69: * @param nameCapacity the size of the name buffer to store the
jpayne@69: * full name with
jpayne@69: * @param err error information if retrieving the full name failed
jpayne@69: * @return the actual buffer size needed for the full name. If it's greater
jpayne@69: * than nameCapacity, the returned full name will be truncated.
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_canonicalize(const char* localeID,
jpayne@69: char* name,
jpayne@69: int32_t nameCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the ISO language code for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the ISO language code with
jpayne@69: * @return language the ISO language code for localeID
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_getISO3Language(const char* localeID);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the ISO country code for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the ISO country code with
jpayne@69: * @return country the ISO country code for localeID
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_getISO3Country(const char* localeID);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the Win32 LCID value for the specified locale.
jpayne@69: * If the ICU locale is not recognized by Windows, 0 will be returned.
jpayne@69: *
jpayne@69: * LCIDs were deprecated with Windows Vista and Microsoft recommends
jpayne@69: * that developers use BCP47 style tags instead (uloc_toLanguageTag).
jpayne@69: *
jpayne@69: * @param localeID the locale to get the Win32 LCID value with
jpayne@69: * @return country the Win32 LCID for localeID
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE uint32_t U_EXPORT2
jpayne@69: uloc_getLCID(const char* localeID);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the language name suitable for display for the specified locale.
jpayne@69: *
jpayne@69: * @param locale the locale to get the ISO language code with
jpayne@69: * @param displayLocale Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "Anglais", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "Englisch".
jpayne@69: * @param language the displayable language code for localeID
jpayne@69: * @param languageCapacity the size of the language buffer to store the
jpayne@69: * displayable language code with
jpayne@69: * @param status error information if retrieving the displayable language code failed
jpayne@69: * @return the actual buffer size needed for the displayable language code. If it's greater
jpayne@69: * than languageCapacity, the returned language code will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayLanguage(const char* locale,
jpayne@69: const char* displayLocale,
jpayne@69: UChar* language,
jpayne@69: int32_t languageCapacity,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the script name suitable for display for the specified locale.
jpayne@69: *
jpayne@69: * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
jpayne@69: * @param displayLocale Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "". NULL may be used to specify the default.
jpayne@69: * @param script the displayable script for the localeID
jpayne@69: * @param scriptCapacity the size of the script buffer to store the
jpayne@69: * displayable script code with
jpayne@69: * @param status error information if retrieving the displayable script code failed
jpayne@69: * @return the actual buffer size needed for the displayable script code. If it's greater
jpayne@69: * than scriptCapacity, the returned displayable script code will be truncated.
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayScript(const char* locale,
jpayne@69: const char* displayLocale,
jpayne@69: UChar* script,
jpayne@69: int32_t scriptCapacity,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the country name suitable for display for the specified locale.
jpayne@69: * Warning: this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
jpayne@69: * To get the display name for a region alone, or for other options, use ULocaleDisplayNames instead.
jpayne@69: *
jpayne@69: * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
jpayne@69: * @param displayLocale Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "Anglais", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "Englisch". NULL may be used to specify the default.
jpayne@69: * @param country the displayable country code for localeID
jpayne@69: * @param countryCapacity the size of the country buffer to store the
jpayne@69: * displayable country code with
jpayne@69: * @param status error information if retrieving the displayable country code failed
jpayne@69: * @return the actual buffer size needed for the displayable country code. If it's greater
jpayne@69: * than countryCapacity, the returned displayable country code will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayCountry(const char* locale,
jpayne@69: const char* displayLocale,
jpayne@69: UChar* country,
jpayne@69: int32_t countryCapacity,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the variant name suitable for display for the specified locale.
jpayne@69: *
jpayne@69: * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
jpayne@69: * @param displayLocale Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "Anglais", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "Englisch". NULL may be used to specify the default.
jpayne@69: * @param variant the displayable variant code for localeID
jpayne@69: * @param variantCapacity the size of the variant buffer to store the
jpayne@69: * displayable variant code with
jpayne@69: * @param status error information if retrieving the displayable variant code failed
jpayne@69: * @return the actual buffer size needed for the displayable variant code. If it's greater
jpayne@69: * than variantCapacity, the returned displayable variant code will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayVariant(const char* locale,
jpayne@69: const char* displayLocale,
jpayne@69: UChar* variant,
jpayne@69: int32_t variantCapacity,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the keyword name suitable for display for the specified locale.
jpayne@69: * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
jpayne@69: * string for the keyword collation.
jpayne@69: * Usage:
jpayne@69: *
jpayne@69: * UErrorCode status = U_ZERO_ERROR;
jpayne@69: * const char* keyword =NULL;
jpayne@69: * int32_t keywordLen = 0;
jpayne@69: * int32_t keywordCount = 0;
jpayne@69: * UChar displayKeyword[256];
jpayne@69: * int32_t displayKeywordLen = 0;
jpayne@69: * UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status);
jpayne@69: * for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){
jpayne@69: * if(U_FAILURE(status)){
jpayne@69: * ...something went wrong so handle the error...
jpayne@69: * break;
jpayne@69: * }
jpayne@69: * // the uenum_next returns NUL terminated string
jpayne@69: * keyword = uenum_next(keywordEnum, &keywordLen, &status);
jpayne@69: * displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256);
jpayne@69: * ... do something interesting .....
jpayne@69: * }
jpayne@69: * uenum_close(keywordEnum);
jpayne@69: *
jpayne@69: * @param keyword The keyword whose display string needs to be returned.
jpayne@69: * @param displayLocale Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "Anglais", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "Englisch". NULL may be used to specify the default.
jpayne@69: * @param dest the buffer to which the displayable keyword should be written.
jpayne@69: * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
jpayne@69: * dest may be NULL and the function will only return the length of the
jpayne@69: * result without writing any of the result string (pre-flighting).
jpayne@69: * @param status error information if retrieving the displayable string failed.
jpayne@69: * Should not be NULL and should not indicate failure on entry.
jpayne@69: * @return the actual buffer size needed for the displayable variant code.
jpayne@69: * @see #uloc_openKeywords
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayKeyword(const char* keyword,
jpayne@69: const char* displayLocale,
jpayne@69: UChar* dest,
jpayne@69: int32_t destCapacity,
jpayne@69: UErrorCode* status);
jpayne@69: /**
jpayne@69: * Gets the value of the keyword suitable for display for the specified locale.
jpayne@69: * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
jpayne@69: * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword.
jpayne@69: *
jpayne@69: * @param locale The locale to get the displayable variant code with. NULL may be used to specify the default.
jpayne@69: * @param keyword The keyword for whose value should be used.
jpayne@69: * @param displayLocale Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "Anglais", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "Englisch". NULL may be used to specify the default.
jpayne@69: * @param dest the buffer to which the displayable keyword should be written.
jpayne@69: * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
jpayne@69: * dest may be NULL and the function will only return the length of the
jpayne@69: * result without writing any of the result string (pre-flighting).
jpayne@69: * @param status error information if retrieving the displayable string failed.
jpayne@69: * Should not be NULL and must not indicate failure on entry.
jpayne@69: * @return the actual buffer size needed for the displayable variant code.
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayKeywordValue( const char* locale,
jpayne@69: const char* keyword,
jpayne@69: const char* displayLocale,
jpayne@69: UChar* dest,
jpayne@69: int32_t destCapacity,
jpayne@69: UErrorCode* status);
jpayne@69: /**
jpayne@69: * Gets the full name suitable for display for the specified locale.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the displayable name with. NULL may be used to specify the default.
jpayne@69: * @param inLocaleID Specifies the locale to be used to display the name. In other words,
jpayne@69: * if the locale's language code is "en", passing Locale::getFrench() for
jpayne@69: * inLocale would result in "Anglais", while passing Locale::getGerman()
jpayne@69: * for inLocale would result in "Englisch". NULL may be used to specify the default.
jpayne@69: * @param result the displayable name for localeID
jpayne@69: * @param maxResultSize the size of the name buffer to store the
jpayne@69: * displayable full name with
jpayne@69: * @param err error information if retrieving the displayable name failed
jpayne@69: * @return the actual buffer size needed for the displayable name. If it's greater
jpayne@69: * than maxResultSize, the returned displayable name will be truncated.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getDisplayName(const char* localeID,
jpayne@69: const char* inLocaleID,
jpayne@69: UChar* result,
jpayne@69: int32_t maxResultSize,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the specified locale from a list of available locales.
jpayne@69: *
jpayne@69: * This method corresponds to uloc_openAvailableByType called with the
jpayne@69: * ULOC_AVAILABLE_DEFAULT type argument.
jpayne@69: *
jpayne@69: * The return value is a pointer to an item of a locale name array. Both this
jpayne@69: * array and the pointers it contains are owned by ICU and should not be
jpayne@69: * deleted or written through by the caller. The locale name is terminated by
jpayne@69: * a null pointer.
jpayne@69: *
jpayne@69: * @param n the specific locale name index of the available locale list;
jpayne@69: * should not exceed the number returned by uloc_countAvailable.
jpayne@69: * @return a specified locale name of all available locales
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_getAvailable(int32_t n);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the size of the all available locale list.
jpayne@69: *
jpayne@69: * @return the size of the locale list
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
jpayne@69:
jpayne@69: #ifndef U_HIDE_DRAFT_API
jpayne@69:
jpayne@69: /**
jpayne@69: * Types for uloc_getAvailableByType and uloc_countAvailableByType.
jpayne@69: *
jpayne@69: * @draft ICU 65
jpayne@69: */
jpayne@69: typedef enum ULocAvailableType {
jpayne@69: /**
jpayne@69: * Locales that return data when passed to ICU APIs,
jpayne@69: * but not including legacy or alias locales.
jpayne@69: *
jpayne@69: * @draft ICU 65
jpayne@69: */
jpayne@69: ULOC_AVAILABLE_DEFAULT,
jpayne@69:
jpayne@69: /**
jpayne@69: * Legacy or alias locales that return data when passed to ICU APIs.
jpayne@69: * Examples of supported legacy or alias locales:
jpayne@69: *
jpayne@69: * - iw (alias to he)
jpayne@69: * - mo (alias to ro)
jpayne@69: * - zh_CN (alias to zh_Hans_CN)
jpayne@69: * - sr_BA (alias to sr_Cyrl_BA)
jpayne@69: * - ars (alias to ar_SA)
jpayne@69: *
jpayne@69: * The locales in this set are disjoint from the ones in
jpayne@69: * ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use
jpayne@69: * ULOC_AVAILABLE_WITH_LEGACY_ALIASES.
jpayne@69: *
jpayne@69: * @draft ICU 65
jpayne@69: */
jpayne@69: ULOC_AVAILABLE_ONLY_LEGACY_ALIASES,
jpayne@69:
jpayne@69: /**
jpayne@69: * The union of the locales in ULOC_AVAILABLE_DEFAULT and
jpayne@69: * ULOC_AVAILABLE_ONLY_LEGACY_ALIAS.
jpayne@69: *
jpayne@69: * @draft ICU 65
jpayne@69: */
jpayne@69: ULOC_AVAILABLE_WITH_LEGACY_ALIASES,
jpayne@69:
jpayne@69: #ifndef U_HIDE_INTERNAL_API
jpayne@69: /**
jpayne@69: * @internal
jpayne@69: */
jpayne@69: ULOC_AVAILABLE_COUNT
jpayne@69: #endif
jpayne@69: } ULocAvailableType;
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets a list of available locales according to the type argument, allowing
jpayne@69: * the user to access different sets of supported locales in ICU.
jpayne@69: *
jpayne@69: * The returned UEnumeration must be closed by the caller.
jpayne@69: *
jpayne@69: * @param type Type choice from ULocAvailableType.
jpayne@69: * @param status Set if an error occurred.
jpayne@69: * @return a UEnumeration owned by the caller, or nullptr on failure.
jpayne@69: * @draft ICU 65
jpayne@69: */
jpayne@69: U_DRAFT UEnumeration* U_EXPORT2
jpayne@69: uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status);
jpayne@69:
jpayne@69: #endif // U_HIDE_DRAFT_API
jpayne@69:
jpayne@69: /**
jpayne@69: *
jpayne@69: * Gets a list of all available 2-letter language codes defined in ISO 639,
jpayne@69: * plus additional 3-letter codes determined to be useful for locale generation as
jpayne@69: * defined by Unicode CLDR. This is a pointer
jpayne@69: * to an array of pointers to arrays of char. All of these pointers are owned
jpayne@69: * by ICU-- do not delete them, and do not write through them. The array is
jpayne@69: * terminated with a null pointer.
jpayne@69: * @return a list of all available language codes
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE const char* const* U_EXPORT2
jpayne@69: uloc_getISOLanguages(void);
jpayne@69:
jpayne@69: /**
jpayne@69: *
jpayne@69: * Gets a list of all available 2-letter country codes defined in ISO 639. This is a
jpayne@69: * pointer to an array of pointers to arrays of char. All of these pointers are
jpayne@69: * owned by ICU-- do not delete them, and do not write through them. The array is
jpayne@69: * terminated with a null pointer.
jpayne@69: * @return a list of all available country codes
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE const char* const* U_EXPORT2
jpayne@69: uloc_getISOCountries(void);
jpayne@69:
jpayne@69: /**
jpayne@69: * Truncate the locale ID string to get the parent locale ID.
jpayne@69: * Copies the part of the string before the last underscore.
jpayne@69: * The parent locale ID will be an empty string if there is no
jpayne@69: * underscore, or if there is only one underscore at localeID[0].
jpayne@69: *
jpayne@69: * @param localeID Input locale ID string.
jpayne@69: * @param parent Output string buffer for the parent locale ID.
jpayne@69: * @param parentCapacity Size of the output buffer.
jpayne@69: * @param err A UErrorCode value.
jpayne@69: * @return The length of the parent locale ID.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getParent(const char* localeID,
jpayne@69: char* parent,
jpayne@69: int32_t parentCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69:
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the full name for the specified locale, like uloc_getName(),
jpayne@69: * but without keywords.
jpayne@69: *
jpayne@69: * Note: This has the effect of 'canonicalizing' the string to
jpayne@69: * a certain extent. Upper and lower case are set as needed,
jpayne@69: * and if the components were in 'POSIX' format they are changed to
jpayne@69: * ICU format. It does NOT map aliased names in any way.
jpayne@69: * See the top of this header file.
jpayne@69: *
jpayne@69: * This API strips off the keyword part, so "de_DE\@collation=phonebook"
jpayne@69: * will become "de_DE".
jpayne@69: * This API supports preflighting.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the full name with
jpayne@69: * @param name fill in buffer for the name without keywords.
jpayne@69: * @param nameCapacity capacity of the fill in buffer.
jpayne@69: * @param err error information if retrieving the full name failed
jpayne@69: * @return the actual buffer size needed for the full name. If it's greater
jpayne@69: * than nameCapacity, the returned full name will be truncated.
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getBaseName(const char* localeID,
jpayne@69: char* name,
jpayne@69: int32_t nameCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets an enumeration of keywords for the specified locale. Enumeration
jpayne@69: * must get disposed of by the client using uenum_close function.
jpayne@69: *
jpayne@69: * @param localeID the locale to get the variant code with
jpayne@69: * @param status error information if retrieving the keywords failed
jpayne@69: * @return enumeration of keywords or NULL if there are no keywords.
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE UEnumeration* U_EXPORT2
jpayne@69: uloc_openKeywords(const char* localeID,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the value for a keyword. Locale name does not need to be normalized.
jpayne@69: *
jpayne@69: * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK")
jpayne@69: * @param keywordName name of the keyword for which we want the value; must not be
jpayne@69: * NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive.
jpayne@69: * @param buffer receiving buffer
jpayne@69: * @param bufferCapacity capacity of receiving buffer
jpayne@69: * @param status containing error code: e.g. buffer not big enough or ill-formed localeID
jpayne@69: * or keywordName parameters.
jpayne@69: * @return the length of keyword value
jpayne@69: * @stable ICU 2.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getKeywordValue(const char* localeID,
jpayne@69: const char* keywordName,
jpayne@69: char* buffer, int32_t bufferCapacity,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets or removes the value of the specified keyword.
jpayne@69: *
jpayne@69: * For removing all keywords, use uloc_getBaseName().
jpayne@69: *
jpayne@69: * NOTE: Unlike almost every other ICU function which takes a
jpayne@69: * buffer, this function will NOT truncate the output text, and will
jpayne@69: * not update the buffer with unterminated text setting a status of
jpayne@69: * U_STRING_NOT_TERMINATED_WARNING. If a BUFFER_OVERFLOW_ERROR is received,
jpayne@69: * it means a terminated version of the updated locale ID would not fit
jpayne@69: * in the buffer, and the original buffer is untouched. This is done to
jpayne@69: * prevent incorrect or possibly even malformed locales from being generated
jpayne@69: * and used.
jpayne@69: *
jpayne@69: * @param keywordName name of the keyword to be set; must not be
jpayne@69: * NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive.
jpayne@69: * @param keywordValue value of the keyword to be set. If 0-length or
jpayne@69: * NULL, will result in the keyword being removed; no error is given if
jpayne@69: * that keyword does not exist. Otherwise, must consist only of
jpayne@69: * [A-Za-z0-9] and [/_+-].
jpayne@69: * @param buffer input buffer containing well-formed locale ID to be
jpayne@69: * modified.
jpayne@69: * @param bufferCapacity capacity of receiving buffer
jpayne@69: * @param status containing error code: e.g. buffer not big enough
jpayne@69: * or ill-formed keywordName or keywordValue parameters, or ill-formed
jpayne@69: * locale ID in buffer on input.
jpayne@69: * @return the length needed for the buffer
jpayne@69: * @see uloc_getKeywordValue
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_setKeywordValue(const char* keywordName,
jpayne@69: const char* keywordValue,
jpayne@69: char* buffer, int32_t bufferCapacity,
jpayne@69: UErrorCode* status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns whether the locale's script is written right-to-left.
jpayne@69: * If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
jpayne@69: * If no likely script is known, then FALSE is returned.
jpayne@69: *
jpayne@69: * A script is right-to-left according to the CLDR script metadata
jpayne@69: * which corresponds to whether the script's letters have Bidi_Class=R or AL.
jpayne@69: *
jpayne@69: * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
jpayne@69: *
jpayne@69: * @param locale input locale ID
jpayne@69: * @return TRUE if the locale's script is written right-to-left
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: U_STABLE UBool U_EXPORT2
jpayne@69: uloc_isRightToLeft(const char *locale);
jpayne@69:
jpayne@69: /**
jpayne@69: * enums for the return value for the character and line orientation
jpayne@69: * functions.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: typedef enum {
jpayne@69: ULOC_LAYOUT_LTR = 0, /* left-to-right. */
jpayne@69: ULOC_LAYOUT_RTL = 1, /* right-to-left. */
jpayne@69: ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */
jpayne@69: ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */
jpayne@69: ULOC_LAYOUT_UNKNOWN
jpayne@69: } ULayoutType;
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the layout character orientation for the specified locale.
jpayne@69: *
jpayne@69: * @param localeId locale name
jpayne@69: * @param status Error status
jpayne@69: * @return an enum indicating the layout orientation for characters.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE ULayoutType U_EXPORT2
jpayne@69: uloc_getCharacterOrientation(const char* localeId,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Get the layout line orientation for the specified locale.
jpayne@69: *
jpayne@69: * @param localeId locale name
jpayne@69: * @param status Error status
jpayne@69: * @return an enum indicating the layout orientation for lines.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE ULayoutType U_EXPORT2
jpayne@69: uloc_getLineOrientation(const char* localeId,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Output values which uloc_acceptLanguage() writes to the 'outResult' parameter.
jpayne@69: *
jpayne@69: * @see uloc_acceptLanguageFromHTTP
jpayne@69: * @see uloc_acceptLanguage
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: typedef enum {
jpayne@69: /**
jpayne@69: * No exact match was found.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: ULOC_ACCEPT_FAILED = 0,
jpayne@69: /**
jpayne@69: * An exact match was found.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: ULOC_ACCEPT_VALID = 1,
jpayne@69: /**
jpayne@69: * A fallback was found. For example, the Accept-Language list includes 'ja_JP'
jpayne@69: * and is matched with available locale 'ja'.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: ULOC_ACCEPT_FALLBACK = 2 /* */
jpayne@69: } UAcceptResult;
jpayne@69:
jpayne@69: /**
jpayne@69: * Based on a HTTP header from a web browser and a list of available locales,
jpayne@69: * determine an acceptable locale for the user.
jpayne@69: *
jpayne@69: * This is a thin wrapper over C++ class LocaleMatcher.
jpayne@69: *
jpayne@69: * @param result - buffer to accept the result locale
jpayne@69: * @param resultAvailable the size of the result buffer.
jpayne@69: * @param outResult - An out parameter that contains the fallback status
jpayne@69: * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP.
jpayne@69: * @param availableLocales - list of available locales to match
jpayne@69: * @param status ICU error code. Its input value must pass the U_SUCCESS() test,
jpayne@69: * or else the function returns immediately. Check for U_FAILURE()
jpayne@69: * on output or use with function chaining. (See User Guide for details.)
jpayne@69: * @return length needed for the locale.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
jpayne@69: UAcceptResult *outResult,
jpayne@69: const char *httpAcceptLanguage,
jpayne@69: UEnumeration* availableLocales,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Based on a list of available locales,
jpayne@69: * determine an acceptable locale for the user.
jpayne@69: *
jpayne@69: * This is a thin wrapper over C++ class LocaleMatcher.
jpayne@69: *
jpayne@69: * @param result - buffer to accept the result locale
jpayne@69: * @param resultAvailable the size of the result buffer.
jpayne@69: * @param outResult - An out parameter that contains the fallback status
jpayne@69: * @param acceptList - list of acceptable languages
jpayne@69: * @param acceptListCount - count of acceptList items
jpayne@69: * @param availableLocales - list of available locales to match
jpayne@69: * @param status ICU error code. Its input value must pass the U_SUCCESS() test,
jpayne@69: * or else the function returns immediately. Check for U_FAILURE()
jpayne@69: * on output or use with function chaining. (See User Guide for details.)
jpayne@69: * @return length needed for the locale.
jpayne@69: * @stable ICU 3.2
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_acceptLanguage(char *result, int32_t resultAvailable,
jpayne@69: UAcceptResult *outResult, const char **acceptList,
jpayne@69: int32_t acceptListCount,
jpayne@69: UEnumeration* availableLocales,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Gets the ICU locale ID for the specified Win32 LCID value.
jpayne@69: *
jpayne@69: * @param hostID the Win32 LCID to translate
jpayne@69: * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated
jpayne@69: * if there is room.
jpayne@69: * @param localeCapacity the size of the output buffer
jpayne@69: * @param status an error is returned if the LCID is unrecognized or the output buffer
jpayne@69: * is too small
jpayne@69: * @return actual the actual size of the locale ID, not including NUL-termination
jpayne@69: * @stable ICU 3.8
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
jpayne@69: UErrorCode *status);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Add the likely subtags for a provided locale ID, per the algorithm described
jpayne@69: * in the following CLDR technical report:
jpayne@69: *
jpayne@69: * http://www.unicode.org/reports/tr35/#Likely_Subtags
jpayne@69: *
jpayne@69: * If localeID is already in the maximal form, or there is no data available
jpayne@69: * for maximization, it will be copied to the output buffer. For example,
jpayne@69: * "und-Zzzz" cannot be maximized, since there is no reasonable maximization.
jpayne@69: *
jpayne@69: * Examples:
jpayne@69: *
jpayne@69: * "en" maximizes to "en_Latn_US"
jpayne@69: *
jpayne@69: * "de" maximizes to "de_Latn_US"
jpayne@69: *
jpayne@69: * "sr" maximizes to "sr_Cyrl_RS"
jpayne@69: *
jpayne@69: * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
jpayne@69: *
jpayne@69: * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
jpayne@69: *
jpayne@69: * @param localeID The locale to maximize
jpayne@69: * @param maximizedLocaleID The maximized locale
jpayne@69: * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer
jpayne@69: * @param err Error information if maximizing the locale failed. If the length
jpayne@69: * of the localeID and the null-terminator is greater than the maximum allowed size,
jpayne@69: * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
jpayne@69: * @return The actual buffer size needed for the maximized locale. If it's
jpayne@69: * greater than maximizedLocaleIDCapacity, the returned ID will be truncated.
jpayne@69: * On error, the return value is -1.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_addLikelySubtags(const char* localeID,
jpayne@69: char* maximizedLocaleID,
jpayne@69: int32_t maximizedLocaleIDCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * Minimize the subtags for a provided locale ID, per the algorithm described
jpayne@69: * in the following CLDR technical report:
jpayne@69: *
jpayne@69: * http://www.unicode.org/reports/tr35/#Likely_Subtags
jpayne@69: *
jpayne@69: * If localeID is already in the minimal form, or there is no data available
jpayne@69: * for minimization, it will be copied to the output buffer. Since the
jpayne@69: * minimization algorithm relies on proper maximization, see the comments
jpayne@69: * for uloc_addLikelySubtags for reasons why there might not be any data.
jpayne@69: *
jpayne@69: * Examples:
jpayne@69: *
jpayne@69: * "en_Latn_US" minimizes to "en"
jpayne@69: *
jpayne@69: * "de_Latn_US" minimizes to "de"
jpayne@69: *
jpayne@69: * "sr_Cyrl_RS" minimizes to "sr"
jpayne@69: *
jpayne@69: * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
jpayne@69: * script, and minimizing to "zh" would imply "zh_Hans_CN".)
jpayne@69: *
jpayne@69: * @param localeID The locale to minimize
jpayne@69: * @param minimizedLocaleID The minimized locale
jpayne@69: * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer
jpayne@69: * @param err Error information if minimizing the locale failed. If the length
jpayne@69: * of the localeID and the null-terminator is greater than the maximum allowed size,
jpayne@69: * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
jpayne@69: * @return The actual buffer size needed for the minimized locale. If it's
jpayne@69: * greater than minimizedLocaleIDCapacity, the returned ID will be truncated.
jpayne@69: * On error, the return value is -1.
jpayne@69: * @stable ICU 4.0
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_minimizeSubtags(const char* localeID,
jpayne@69: char* minimizedLocaleID,
jpayne@69: int32_t minimizedLocaleIDCapacity,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Returns a locale ID for the specified BCP47 language tag string.
jpayne@69: * If the specified language tag contains any ill-formed subtags,
jpayne@69: * the first such subtag and all following subtags are ignored.
jpayne@69: *
jpayne@69: * This implements the 'Language-Tag' production of BCP47, and so jpayne@69: * supports grandfathered (regular and irregular) as well as private jpayne@69: * use language tags. Private use tags are represented as 'x-whatever', jpayne@69: * and grandfathered tags are converted to their canonical replacements jpayne@69: * where they exist. Note that a few grandfathered tags have no modern jpayne@69: * replacement, these will be converted using the fallback described in jpayne@69: * the first paragraph, so some information might be lost. jpayne@69: * @param langtag the input BCP47 language tag. jpayne@69: * @param localeID the output buffer receiving a locale ID for the jpayne@69: * specified BCP47 language tag. jpayne@69: * @param localeIDCapacity the size of the locale ID output buffer. jpayne@69: * @param parsedLength if not NULL, successfully parsed length jpayne@69: * for the input language tag is set. jpayne@69: * @param err error information if receiving the locald ID jpayne@69: * failed. jpayne@69: * @return the length of the locale ID. jpayne@69: * @stable ICU 4.2 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uloc_forLanguageTag(const char* langtag, jpayne@69: char* localeID, jpayne@69: int32_t localeIDCapacity, jpayne@69: int32_t* parsedLength, jpayne@69: UErrorCode* err); jpayne@69: jpayne@69: /** jpayne@69: * Returns a well-formed language tag for this locale ID. jpayne@69: *
jpayne@69: * Note: When strict
is FALSE, any locale
jpayne@69: * fields which do not satisfy the BCP47 syntax requirement will
jpayne@69: * be omitted from the result. When strict
is
jpayne@69: * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
jpayne@69: * err
if any locale fields do not satisfy the
jpayne@69: * BCP47 syntax requirement.
jpayne@69: * @param localeID the input locale ID
jpayne@69: * @param langtag the output buffer receiving BCP47 language
jpayne@69: * tag for the locale ID.
jpayne@69: * @param langtagCapacity the size of the BCP47 language tag
jpayne@69: * output buffer.
jpayne@69: * @param strict boolean value indicating if the function returns
jpayne@69: * an error for an ill-formed input locale ID.
jpayne@69: * @param err error information if receiving the language
jpayne@69: * tag failed.
jpayne@69: * @return The length of the BCP47 language tag.
jpayne@69: * @stable ICU 4.2
jpayne@69: */
jpayne@69: U_STABLE int32_t U_EXPORT2
jpayne@69: uloc_toLanguageTag(const char* localeID,
jpayne@69: char* langtag,
jpayne@69: int32_t langtagCapacity,
jpayne@69: UBool strict,
jpayne@69: UErrorCode* err);
jpayne@69:
jpayne@69: /**
jpayne@69: * Converts the specified keyword (legacy key, or BCP 47 Unicode locale
jpayne@69: * extension key) to the equivalent BCP 47 Unicode locale extension key.
jpayne@69: * For example, BCP 47 Unicode locale extension key "co" is returned for
jpayne@69: * the input keyword "collation".
jpayne@69: *
jpayne@69: * When the specified keyword is unknown, but satisfies the BCP syntax,
jpayne@69: * then the pointer to the input keyword itself will be returned.
jpayne@69: * For example,
jpayne@69: * uloc_toUnicodeLocaleKey("ZZ")
returns "ZZ".
jpayne@69: *
jpayne@69: * @param keyword the input locale keyword (either legacy key
jpayne@69: * such as "collation" or BCP 47 Unicode locale extension
jpayne@69: * key such as "co").
jpayne@69: * @return the well-formed BCP 47 Unicode locale extension key,
jpayne@69: * or NULL if the specified locale keyword cannot be
jpayne@69: * mapped to a well-formed BCP 47 Unicode locale extension
jpayne@69: * key.
jpayne@69: * @see uloc_toLegacyKey
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_toUnicodeLocaleKey(const char* keyword);
jpayne@69:
jpayne@69: /**
jpayne@69: * Converts the specified keyword value (legacy type, or BCP 47
jpayne@69: * Unicode locale extension type) to the well-formed BCP 47 Unicode locale
jpayne@69: * extension type for the specified keyword (category). For example, BCP 47
jpayne@69: * Unicode locale extension type "phonebk" is returned for the input
jpayne@69: * keyword value "phonebook", with the keyword "collation" (or "co").
jpayne@69: *
jpayne@69: * When the specified keyword is not recognized, but the specified value
jpayne@69: * satisfies the syntax of the BCP 47 Unicode locale extension type,
jpayne@69: * or when the specified keyword allows 'variable' type and the specified
jpayne@69: * value satisfies the syntax, then the pointer to the input type value itself
jpayne@69: * will be returned.
jpayne@69: * For example,
jpayne@69: * uloc_toUnicodeLocaleType("Foo", "Bar")
returns "Bar",
jpayne@69: * uloc_toUnicodeLocaleType("variableTop", "00A4")
returns "00A4".
jpayne@69: *
jpayne@69: * @param keyword the locale keyword (either legacy key such as
jpayne@69: * "collation" or BCP 47 Unicode locale extension
jpayne@69: * key such as "co").
jpayne@69: * @param value the locale keyword value (either legacy type
jpayne@69: * such as "phonebook" or BCP 47 Unicode locale extension
jpayne@69: * type such as "phonebk").
jpayne@69: * @return the well-formed BCP47 Unicode locale extension type,
jpayne@69: * or NULL if the locale keyword value cannot be mapped to
jpayne@69: * a well-formed BCP 47 Unicode locale extension type.
jpayne@69: * @see uloc_toLegacyType
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_toUnicodeLocaleType(const char* keyword, const char* value);
jpayne@69:
jpayne@69: /**
jpayne@69: * Converts the specified keyword (BCP 47 Unicode locale extension key, or
jpayne@69: * legacy key) to the legacy key. For example, legacy key "collation" is
jpayne@69: * returned for the input BCP 47 Unicode locale extension key "co".
jpayne@69: *
jpayne@69: * @param keyword the input locale keyword (either BCP 47 Unicode locale
jpayne@69: * extension key or legacy key).
jpayne@69: * @return the well-formed legacy key, or NULL if the specified
jpayne@69: * keyword cannot be mapped to a well-formed legacy key.
jpayne@69: * @see toUnicodeLocaleKey
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_toLegacyKey(const char* keyword);
jpayne@69:
jpayne@69: /**
jpayne@69: * Converts the specified keyword value (BCP 47 Unicode locale extension type,
jpayne@69: * or legacy type or type alias) to the canonical legacy type. For example,
jpayne@69: * the legacy type "phonebook" is returned for the input BCP 47 Unicode
jpayne@69: * locale extension type "phonebk" with the keyword "collation" (or "co").
jpayne@69: *
jpayne@69: * When the specified keyword is not recognized, but the specified value
jpayne@69: * satisfies the syntax of legacy key, or when the specified keyword
jpayne@69: * allows 'variable' type and the specified value satisfies the syntax,
jpayne@69: * then the pointer to the input type value itself will be returned.
jpayne@69: * For example,
jpayne@69: * uloc_toLegacyType("Foo", "Bar")
returns "Bar",
jpayne@69: * uloc_toLegacyType("vt", "00A4")
returns "00A4".
jpayne@69: *
jpayne@69: * @param keyword the locale keyword (either legacy keyword such as
jpayne@69: * "collation" or BCP 47 Unicode locale extension
jpayne@69: * key such as "co").
jpayne@69: * @param value the locale keyword value (either BCP 47 Unicode locale
jpayne@69: * extension type such as "phonebk" or legacy keyword value
jpayne@69: * such as "phonebook").
jpayne@69: * @return the well-formed legacy type, or NULL if the specified
jpayne@69: * keyword value cannot be mapped to a well-formed legacy
jpayne@69: * type.
jpayne@69: * @see toUnicodeLocaleType
jpayne@69: * @stable ICU 54
jpayne@69: */
jpayne@69: U_STABLE const char* U_EXPORT2
jpayne@69: uloc_toLegacyType(const char* keyword, const char* value);
jpayne@69:
jpayne@69: #endif /*_ULOC*/