sl@0: /* sl@0: ********************************************************************** sl@0: * Copyright (C) 1997-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: ********************************************************************** sl@0: * sl@0: * File ULOC.H sl@0: * sl@0: * Modification History: sl@0: * sl@0: * Date Name Description sl@0: * 04/01/97 aliu Creation. sl@0: * 08/22/98 stephen JDK 1.2 sync. sl@0: * 12/08/98 rtg New C API for Locale sl@0: * 03/30/99 damiba overhaul sl@0: * 03/31/99 helena Javadoc for uloc functions. sl@0: * 04/15/99 Madhu Updated Javadoc sl@0: ******************************************************************************** sl@0: */ sl@0: sl@0: #ifndef ULOC_H sl@0: #define ULOC_H sl@0: sl@0: #include "unicode/utypes.h" sl@0: #include "unicode/uenum.h" sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C API: Locale sl@0: * sl@0: *

ULoc C API for Locale

sl@0: * A Locale represents a specific geographical, political, sl@0: * or cultural region. An operation that requires a Locale to perform sl@0: * its task is called locale-sensitive and uses the Locale sl@0: * to tailor information for the user. For example, displaying a number sl@0: * is a locale-sensitive operation--the number should be formatted sl@0: * according to the customs/conventions of the user's native country, sl@0: * region, or culture. In the C APIs, a locales is simply a const char string. sl@0: * sl@0: *

sl@0: * You create a Locale with one of the three options listed below. sl@0: * Each of the component is separated by '_' in the locale string. sl@0: * \htmlonly

\endhtmlonly sl@0: *
sl@0:  * \code
sl@0:  *       newLanguage
sl@0:  * 
sl@0:  *       newLanguage + newCountry
sl@0:  * 
sl@0:  *       newLanguage + newCountry + newVariant
sl@0:  * \endcode
sl@0:  * 
sl@0: * \htmlonly
\endhtmlonly sl@0: * The first option is a valid ISO sl@0: * Language Code. These codes are the lower-case two-letter sl@0: * codes as defined by ISO-639. sl@0: * You can find a full list of these codes at a number of sites, such as: sl@0: *
sl@0: * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt sl@0: * sl@0: *

sl@0: * The second option includes an additonal ISO Country sl@0: * Code. These codes are the upper-case two-letter codes sl@0: * as defined by ISO-3166. sl@0: * You can find a full list of these codes at a number of sites, such as: sl@0: *
sl@0: * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html sl@0: * sl@0: *

sl@0: * The third option requires another additonal information--the sl@0: * Variant. sl@0: * The Variant codes are vendor and browser-specific. sl@0: * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. sl@0: * Where there are two variants, separate them with an underscore, and sl@0: * put the most important one first. For sl@0: * example, a Traditional Spanish collation might be referenced, with sl@0: * "ES", "ES", "Traditional_WIN". sl@0: * sl@0: *

sl@0: * Because a Locale is just an identifier for a region, sl@0: * no validity check is performed when you specify a Locale. sl@0: * If you want to see whether particular resources are available for the sl@0: * Locale you asked for, you must query those resources. For sl@0: * example, ask the UNumberFormat for the locales it supports sl@0: * using its getAvailable method. sl@0: *
Note: When you ask for a resource for a particular sl@0: * locale, you get back the best available match, not necessarily sl@0: * precisely what you asked for. For more information, look at sl@0: * UResourceBundle. sl@0: * sl@0: *

sl@0: * The Locale provides a number of convenient constants sl@0: * that you can use to specify the commonly used sl@0: * locales. For example, the following refers to a locale sl@0: * for the United States: sl@0: * \htmlonly

\endhtmlonly sl@0: *
sl@0:  * \code
sl@0:  *       ULOC_US
sl@0:  * \endcode
sl@0:  * 
sl@0: * \htmlonly
\endhtmlonly sl@0: * sl@0: *

sl@0: * Once you've specified a locale you can query it for information about sl@0: * itself. Use uloc_getCountry to get the ISO Country Code and sl@0: * uloc_getLanguage to get the ISO Language Code. You can sl@0: * use uloc_getDisplayCountry to get the sl@0: * name of the country suitable for displaying to the user. Similarly, sl@0: * you can use uloc_getDisplayLanguage to get the name of sl@0: * the language suitable for displaying to the user. Interestingly, sl@0: * the uloc_getDisplayXXX methods are themselves locale-sensitive sl@0: * and have two versions: one that uses the default locale and one sl@0: * that takes a locale as an argument and displays the name or country in sl@0: * a language appropriate to that locale. sl@0: * sl@0: *

sl@0: * The ICU provides a number of services that perform locale-sensitive sl@0: * operations. For example, the unum_xxx functions format sl@0: * numbers, currency, or percentages in a locale-sensitive manner. sl@0: *

sl@0: * \htmlonly
\endhtmlonly sl@0: *
sl@0:  * \code
sl@0:  *     UErrorCode success = U_ZERO_ERROR;
sl@0:  *     UNumberFormat *nf;
sl@0:  *     const char* myLocale = "fr_FR";
sl@0:  * 
sl@0:  *     nf = unum_open( UNUM_DEFAULT, NULL, success );          
sl@0:  *     unum_close(nf);
sl@0:  *     nf = unum_open( UNUM_CURRENCY, NULL, success );
sl@0:  *     unum_close(nf);
sl@0:  *     nf = unum_open( UNUM_PERCENT, NULL, success );   
sl@0:  *     unum_close(nf);
sl@0:  * \endcode
sl@0:  * 
sl@0: * \htmlonly
\endhtmlonly sl@0: * Each of these methods has two variants; one with an explicit locale sl@0: * and one without; the latter using the default locale. sl@0: * \htmlonly
\endhtmlonly sl@0: *
sl@0:  * \code 
sl@0:  * 
sl@0:  *     nf = unum_open( UNUM_DEFAULT, myLocale, success );          
sl@0:  *     unum_close(nf);
sl@0:  *     nf = unum_open( UNUM_CURRENCY, myLocale, success );
sl@0:  *     unum_close(nf);
sl@0:  *     nf = unum_open( UNUM_PERCENT, myLocale, success );   
sl@0:  *     unum_close(nf);
sl@0:  * \endcode
sl@0:  * 
sl@0: * \htmlonly
\endhtmlonly sl@0: * A Locale is the mechanism for identifying the kind of services sl@0: * (UNumberFormat) that you would like to get. The locale is sl@0: * just a mechanism for identifying these services. sl@0: * sl@0: *

sl@0: * Each international serivce that performs locale-sensitive operations sl@0: * allows you sl@0: * to get all the available objects of that type. You can sift sl@0: * through these objects by language, country, or variant, sl@0: * and use the display names to present a menu to the user. sl@0: * For example, you can create a menu of all the collation objects sl@0: * suitable for a given language. Such classes implement these sl@0: * three class methods: sl@0: * \htmlonly

\endhtmlonly sl@0: *
sl@0:  * \code
sl@0:  *       const char* uloc_getAvailable(int32_t index);
sl@0:  *       int32_t uloc_countAvailable();
sl@0:  *       int32_t
sl@0:  *       uloc_getDisplayName(const char* localeID,
sl@0:  *                 const char* inLocaleID, 
sl@0:  *                 UChar* result,
sl@0:  *                 int32_t maxResultSize,
sl@0:  *                  UErrorCode* err);
sl@0:  * 
sl@0:  * \endcode
sl@0:  * 
sl@0: * \htmlonly
\endhtmlonly sl@0: *

sl@0: * Concerning POSIX/RFC1766 Locale IDs, sl@0: * the getLanguage/getCountry/getVariant/getName functions do understand sl@0: * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT sl@0: * and if there is not an ICU-stype variant, uloc_getVariant() for example sl@0: * will return the one listed after the \@at sign. As well, the hyphen sl@0: * "-" is recognized as a country/variant separator similarly to RFC1766. sl@0: * So for example, "en-us" will be interpreted as en_US. sl@0: * As a result, uloc_getName() is far from a no-op, and will have the sl@0: * effect of converting POSIX/RFC1766 IDs into ICU form, although it does sl@0: * NOT map any of the actual codes (i.e. russian->ru) in any way. sl@0: * Applications should call uloc_getName() at the point where a locale ID sl@0: * is coming from an external source (user entry, OS, web browser) sl@0: * and pass the resulting string to other ICU functions. For example, sl@0: * don't use de-de\@EURO as an argument to resourcebundle. sl@0: * sl@0: * @see UResourceBundle sl@0: */ sl@0: sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_CHINESE "zh" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_ENGLISH "en" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_FRENCH "fr" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_GERMAN "de" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_ITALIAN "it" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_JAPANESE "ja" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_KOREAN "ko" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_SIMPLIFIED_CHINESE "zh_CN" sl@0: /** Useful constant for this language. @stable ICU 2.0 */ sl@0: #define ULOC_TRADITIONAL_CHINESE "zh_TW" sl@0: sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_CANADA "en_CA" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_CANADA_FRENCH "fr_CA" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_CHINA "zh_CN" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_PRC "zh_CN" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_FRANCE "fr_FR" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_GERMANY "de_DE" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_ITALY "it_IT" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_JAPAN "ja_JP" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_KOREA "ko_KR" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_TAIWAN "zh_TW" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_UK "en_GB" sl@0: /** Useful constant for this country/region. @stable ICU 2.0 */ sl@0: #define ULOC_US "en_US" sl@0: sl@0: /** sl@0: * Useful constant for the maximum size of the language part of a locale ID. sl@0: * (including the terminating NULL). sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define ULOC_LANG_CAPACITY 12 sl@0: sl@0: /** sl@0: * Useful constant for the maximum size of the country part of a locale ID sl@0: * (including the terminating NULL). sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define ULOC_COUNTRY_CAPACITY 4 sl@0: /** sl@0: * Useful constant for the maximum size of the whole locale ID sl@0: * (including the terminating NULL). sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define ULOC_FULLNAME_CAPACITY 56 sl@0: sl@0: sl@0: #ifndef U_HIDE_DRAFT_API sl@0: sl@0: /** sl@0: * Useful constant for the maximum size of the script part of a locale ID sl@0: * (including the terminating NULL). sl@0: * @internal ICU 2.8 sl@0: */ sl@0: #define ULOC_SCRIPT_CAPACITY 6 sl@0: sl@0: /** sl@0: * Useful constant for the maximum size of keywords in a locale sl@0: * @internal ICU 2.8 sl@0: */ sl@0: #define ULOC_KEYWORDS_CAPACITY 50 sl@0: sl@0: /** sl@0: * Useful constant for the maximum size of keywords in a locale sl@0: * @internal ICU 2.8 sl@0: */ sl@0: #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100 sl@0: sl@0: /** sl@0: * Character separating keywords from the locale string sl@0: * different for EBCDIC - TODO sl@0: * @stable ICU 2.8 sl@0: */ sl@0: #define ULOC_KEYWORD_SEPARATOR '@' sl@0: /** sl@0: * Character for assigning value to a keyword sl@0: * @stable ICU 2.8 sl@0: */ sl@0: #define ULOC_KEYWORD_ASSIGN '=' sl@0: /** sl@0: * Character separating keywords sl@0: * @stable ICU 2.8 sl@0: */ sl@0: #define ULOC_KEYWORD_ITEM_SEPARATOR ';' sl@0: sl@0: #endif /*U_HIDE_DRAFT_API*/ sl@0: sl@0: /** sl@0: * Constants for *_getLocale() sl@0: * Allow user to select whether she wants information on sl@0: * requested, valid or actual locale. sl@0: * For example, a collator for "en_US_CALIFORNIA" was sl@0: * requested. In the current state of ICU (2.0), sl@0: * the requested locale is "en_US_CALIFORNIA", sl@0: * the valid locale is "en_US" (most specific locale supported by ICU) sl@0: * and the actual locale is "root" (the collation data comes unmodified sl@0: * from the UCA) sl@0: * The locale is considered supported by ICU if there is a core ICU bundle sl@0: * for that locale (although it may be empty). sl@0: * @stable ICU 2.1 sl@0: */ sl@0: typedef enum { sl@0: /** This is locale the data actually comes from sl@0: * @stable ICU 2.1 sl@0: */ sl@0: ULOC_ACTUAL_LOCALE = 0, sl@0: /** This is the most specific locale supported by ICU sl@0: * @stable ICU 2.1 sl@0: */ sl@0: ULOC_VALID_LOCALE = 1, sl@0: sl@0: #ifndef U_HIDE_DEPRECATED_API sl@0: /** This is the requested locale sl@0: * @deprecated ICU 2.8 sl@0: */ sl@0: ULOC_REQUESTED_LOCALE = 2, sl@0: #endif /* U_HIDE_DEPRECATED_API */ sl@0: sl@0: ULOC_DATA_LOCALE_TYPE_LIMIT sl@0: } ULocDataLocaleType ; sl@0: sl@0: sl@0: /** sl@0: * Gets ICU's default locale. sl@0: * The returned string is a snapshot in time, and will remain valid sl@0: * and unchanged even when uloc_setDefault() is called. sl@0: * The returned storage is owned by ICU, and must not be altered or deleted sl@0: * by the caller. sl@0: * sl@0: * @return the ICU default locale sl@0: * @system sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* U_EXPORT2 sl@0: uloc_getDefault(void); sl@0: sl@0: /** sl@0: * Sets ICU's default locale. sl@0: * By default (without calling this function), ICU's default locale will be based sl@0: * on information obtained from the underlying system environment. sl@0: *

sl@0: * Changes to ICU's default locale do not propagate back to the sl@0: * system environment. sl@0: *

sl@0: * Changes to ICU's default locale to not affect any ICU services that sl@0: * may already be open based on the previous default locale value. sl@0: * sl@0: * @param localeID the new ICU default locale. A value of NULL will try to get sl@0: * the system's default locale. sl@0: * @param status the error information if the setting of default locale fails sl@0: * @system sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: uloc_setDefault(const char* localeID, sl@0: UErrorCode* status); sl@0: sl@0: /** sl@0: * Gets the language code for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the ISO language code with sl@0: * @param language the language code for localeID sl@0: * @param languageCapacity the size of the language buffer to store the sl@0: * language code with sl@0: * @param err error information if retrieving the language code failed sl@0: * @return the actual buffer size needed for the language code. If it's greater sl@0: * than languageCapacity, the returned language code will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getLanguage(const char* localeID, sl@0: char* language, sl@0: int32_t languageCapacity, sl@0: UErrorCode* err); sl@0: sl@0: /** sl@0: * Gets the script code for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the ISO language code with sl@0: * @param script the language code for localeID sl@0: * @param scriptCapacity the size of the language buffer to store the sl@0: * language code with sl@0: * @param err error information if retrieving the language code failed sl@0: * @return the actual buffer size needed for the language code. If it's greater sl@0: * than scriptCapacity, the returned language code will be truncated. sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getScript(const char* localeID, sl@0: char* script, sl@0: int32_t scriptCapacity, sl@0: UErrorCode* err); sl@0: sl@0: /** sl@0: * Gets the country code for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the country code with sl@0: * @param country the country code for localeID sl@0: * @param countryCapacity the size of the country buffer to store the sl@0: * country code with sl@0: * @param err error information if retrieving the country code failed sl@0: * @return the actual buffer size needed for the country code. If it's greater sl@0: * than countryCapacity, the returned country code will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: uloc_getCountry(const char* localeID, sl@0: char* country, sl@0: int32_t countryCapacity, sl@0: UErrorCode* err); sl@0: sl@0: /** sl@0: * Gets the variant code for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the variant code with sl@0: * @param variant the variant code for localeID sl@0: * @param variantCapacity the size of the variant buffer to store the sl@0: * variant code with sl@0: * @param err error information if retrieving the variant code failed sl@0: * @return the actual buffer size needed for the variant code. If it's greater sl@0: * than variantCapacity, the returned variant code will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getVariant(const char* localeID, sl@0: char* variant, sl@0: int32_t variantCapacity, sl@0: UErrorCode* err); sl@0: sl@0: sl@0: /** sl@0: * Gets the full name for the specified locale. sl@0: * Note: This has the effect of 'canonicalizing' the ICU locale ID to sl@0: * a certain extent. Upper and lower case are set as needed. sl@0: * It does NOT map aliased names in any way. sl@0: * See the top of this header file. sl@0: * This API supports preflighting. sl@0: * sl@0: * @param localeID the locale to get the full name with sl@0: * @param name fill in buffer for the name without keywords. sl@0: * @param nameCapacity capacity of the fill in buffer. sl@0: * @param err error information if retrieving the full name failed sl@0: * @return the actual buffer size needed for the full name. If it's greater sl@0: * than nameCapacity, the returned full name will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getName(const char* localeID, sl@0: char* name, sl@0: int32_t nameCapacity, sl@0: UErrorCode* err); sl@0: sl@0: /** sl@0: * Gets the full name for the specified locale. sl@0: * Note: This has the effect of 'canonicalizing' the string to sl@0: * a certain extent. Upper and lower case are set as needed, sl@0: * and if the components were in 'POSIX' format they are changed to sl@0: * ICU format. It does NOT map aliased names in any way. sl@0: * See the top of this header file. sl@0: * sl@0: * @param localeID the locale to get the full name with sl@0: * @param name the full name for localeID sl@0: * @param nameCapacity the size of the name buffer to store the sl@0: * full name with sl@0: * @param err error information if retrieving the full name failed sl@0: * @return the actual buffer size needed for the full name. If it's greater sl@0: * than nameCapacity, the returned full name will be truncated. sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_canonicalize(const char* localeID, sl@0: char* name, sl@0: int32_t nameCapacity, sl@0: UErrorCode* err); sl@0: sl@0: /** sl@0: * Gets the ISO language code for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the ISO language code with sl@0: * @return language the ISO language code for localeID sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* U_EXPORT2 sl@0: uloc_getISO3Language(const char* localeID); sl@0: sl@0: sl@0: /** sl@0: * Gets the ISO country code for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the ISO country code with sl@0: * @return country the ISO country code for localeID sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* U_EXPORT2 sl@0: uloc_getISO3Country(const char* localeID); sl@0: sl@0: /** sl@0: * Gets the Win32 LCID value for the specified locale. sl@0: * If the ICU locale is not recognized by Windows, 0 will be returned. sl@0: * sl@0: * @param localeID the locale to get the Win32 LCID value with sl@0: * @return country the Win32 LCID for localeID sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE uint32_t U_EXPORT2 sl@0: uloc_getLCID(const char* localeID); sl@0: sl@0: /** sl@0: * Gets the language name suitable for display for the specified locale. sl@0: * sl@0: * @param locale the locale to get the ISO language code with sl@0: * @param displayLocale Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "Anglais", while passing Locale::getGerman() sl@0: * for inLocale would result in "Englisch". sl@0: * @param language the displayable language code for localeID sl@0: * @param languageCapacity the size of the language buffer to store the sl@0: * displayable language code with sl@0: * @param status error information if retrieving the displayable language code failed sl@0: * @return the actual buffer size needed for the displayable language code. If it's greater sl@0: * than languageCapacity, the returned language code will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayLanguage(const char* locale, sl@0: const char* displayLocale, sl@0: UChar* language, sl@0: int32_t languageCapacity, sl@0: UErrorCode* status); sl@0: sl@0: /** sl@0: * Gets the script name suitable for display for the specified locale. sl@0: * sl@0: * @param locale the locale to get the displayable script code with. NULL may be used to specify the default. sl@0: * @param displayLocale Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "", while passing Locale::getGerman() sl@0: * for inLocale would result in "". NULL may be used to specify the default. sl@0: * @param script the displayable country code for localeID sl@0: * @param scriptCapacity the size of the script buffer to store the sl@0: * displayable script code with sl@0: * @param status error information if retrieving the displayable script code failed sl@0: * @return the actual buffer size needed for the displayable script code. If it's greater sl@0: * than scriptCapacity, the returned displayable script code will be truncated. sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayScript(const char* locale, sl@0: const char* displayLocale, sl@0: UChar* script, sl@0: int32_t scriptCapacity, sl@0: UErrorCode* status); sl@0: sl@0: /** sl@0: * Gets the country name suitable for display for the specified locale. sl@0: * sl@0: * @param locale the locale to get the displayable country code with. NULL may be used to specify the default. sl@0: * @param displayLocale Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "Anglais", while passing Locale::getGerman() sl@0: * for inLocale would result in "Englisch". NULL may be used to specify the default. sl@0: * @param country the displayable country code for localeID sl@0: * @param countryCapacity the size of the country buffer to store the sl@0: * displayable country code with sl@0: * @param status error information if retrieving the displayable country code failed sl@0: * @return the actual buffer size needed for the displayable country code. If it's greater sl@0: * than countryCapacity, the returned displayable country code will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayCountry(const char* locale, sl@0: const char* displayLocale, sl@0: UChar* country, sl@0: int32_t countryCapacity, sl@0: UErrorCode* status); sl@0: sl@0: sl@0: /** sl@0: * Gets the variant name suitable for display for the specified locale. sl@0: * sl@0: * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default. sl@0: * @param displayLocale Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "Anglais", while passing Locale::getGerman() sl@0: * for inLocale would result in "Englisch". NULL may be used to specify the default. sl@0: * @param variant the displayable variant code for localeID sl@0: * @param variantCapacity the size of the variant buffer to store the sl@0: * displayable variant code with sl@0: * @param status error information if retrieving the displayable variant code failed sl@0: * @return the actual buffer size needed for the displayable variant code. If it's greater sl@0: * than variantCapacity, the returned displayable variant code will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayVariant(const char* locale, sl@0: const char* displayLocale, sl@0: UChar* variant, sl@0: int32_t variantCapacity, sl@0: UErrorCode* status); sl@0: sl@0: /** sl@0: * Gets the keyword name suitable for display for the specified locale. sl@0: * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display sl@0: * string for the keyword collation. sl@0: * Usage: sl@0: * sl@0: * UErrorCode status = U_ZERO_ERROR; sl@0: * const char* keyword =NULL; sl@0: * int32_t keywordLen = 0; sl@0: * int32_t keywordCount = 0; sl@0: * UChar displayKeyword[256]; sl@0: * int32_t displayKeywordLen = 0; sl@0: * UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status); sl@0: * for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){ sl@0: * if(U_FAILURE(status)){ sl@0: * ...something went wrong so handle the error... sl@0: * break; sl@0: * } sl@0: * // the uenum_next returns NUL terminated string sl@0: * keyword = uenum_next(keywordEnum, &keywordLen, &status); sl@0: * displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256); sl@0: * ... do something interesting ..... sl@0: * } sl@0: * uenum_close(keywordEnum); sl@0: * sl@0: * @param keyword The keyword whose display string needs to be returned. sl@0: * @param displayLocale Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "Anglais", while passing Locale::getGerman() sl@0: * for inLocale would result in "Englisch". NULL may be used to specify the default. sl@0: * @param dest the buffer to which the displayable keyword should be written. sl@0: * @param destCapacity The size of the buffer (number of UChars). If it is 0, then sl@0: * dest may be NULL and the function will only return the length of the sl@0: * result without writing any of the result string (pre-flighting). sl@0: * @param status error information if retrieving the displayable string failed. sl@0: * Should not be NULL and should not indicate failure on entry. sl@0: * @return the actual buffer size needed for the displayable variant code. sl@0: * @see #uloc_openKeywords sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayKeyword(const char* keyword, sl@0: const char* displayLocale, sl@0: UChar* dest, sl@0: int32_t destCapacity, sl@0: UErrorCode* status); sl@0: /** sl@0: * Gets the value of the keyword suitable for display for the specified locale. sl@0: * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display sl@0: * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword. sl@0: * sl@0: * @param locale The locale to get the displayable variant code with. NULL may be used to specify the default. sl@0: * @param keyword The keyword for whose value should be used. sl@0: * @param displayLocale Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "Anglais", while passing Locale::getGerman() sl@0: * for inLocale would result in "Englisch". NULL may be used to specify the default. sl@0: * @param dest the buffer to which the displayable keyword should be written. sl@0: * @param destCapacity The size of the buffer (number of UChars). If it is 0, then sl@0: * dest may be NULL and the function will only return the length of the sl@0: * result without writing any of the result string (pre-flighting). sl@0: * @param status error information if retrieving the displayable string failed. sl@0: * Should not be NULL and must not indicate failure on entry. sl@0: * @return the actual buffer size needed for the displayable variant code. sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayKeywordValue( const char* locale, sl@0: const char* keyword, sl@0: const char* displayLocale, sl@0: UChar* dest, sl@0: int32_t destCapacity, sl@0: UErrorCode* status); sl@0: /** sl@0: * Gets the full name suitable for display for the specified locale. sl@0: * sl@0: * @param localeID the locale to get the displayable name with. NULL may be used to specify the default. sl@0: * @param inLocaleID Specifies the locale to be used to display the name. In other words, sl@0: * if the locale's language code is "en", passing Locale::getFrench() for sl@0: * inLocale would result in "Anglais", while passing Locale::getGerman() sl@0: * for inLocale would result in "Englisch". NULL may be used to specify the default. sl@0: * @param result the displayable name for localeID sl@0: * @param maxResultSize the size of the name buffer to store the sl@0: * displayable full name with sl@0: * @param err error information if retrieving the displayable name failed sl@0: * @return the actual buffer size needed for the displayable name. If it's greater sl@0: * than maxResultSize, the returned displayable name will be truncated. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getDisplayName(const char* localeID, sl@0: const char* inLocaleID, sl@0: UChar* result, sl@0: int32_t maxResultSize, sl@0: UErrorCode* err); sl@0: sl@0: sl@0: /** sl@0: * Gets the specified locale from a list of all available locales. sl@0: * The return value is a pointer to an item of sl@0: * a locale name array. Both this array and the pointers sl@0: * it contains are owned by ICU and should not be deleted or written through sl@0: * by the caller. The locale name is terminated by a null pointer. sl@0: * @param n the specific locale name index of the available locale list sl@0: * @return a specified locale name of all available locales sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* U_EXPORT2 sl@0: uloc_getAvailable(int32_t n); sl@0: sl@0: /** sl@0: * Gets the size of the all available locale list. sl@0: * sl@0: * @return the size of the locale list sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void); sl@0: sl@0: /** sl@0: * sl@0: * Gets a list of all available language codes defined in ISO 639. This is a pointer sl@0: * to an array of pointers to arrays of char. All of these pointers are owned sl@0: * by ICU-- do not delete them, and do not write through them. The array is sl@0: * terminated with a null pointer. sl@0: * @return a list of all available language codes sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* const* U_EXPORT2 sl@0: uloc_getISOLanguages(void); sl@0: sl@0: /** sl@0: * sl@0: * Gets a list of all available 2-letter country codes defined in ISO 639. This is a sl@0: * pointer to an array of pointers to arrays of char. All of these pointers are sl@0: * owned by ICU-- do not delete them, and do not write through them. The array is sl@0: * terminated with a null pointer. sl@0: * @return a list of all available country codes sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* const* U_EXPORT2 sl@0: uloc_getISOCountries(void); sl@0: sl@0: /** sl@0: * Truncate the locale ID string to get the parent locale ID. sl@0: * Copies the part of the string before the last underscore. sl@0: * The parent locale ID will be an empty string if there is no sl@0: * underscore, or if there is only one underscore at localeID[0]. sl@0: * sl@0: * @param localeID Input locale ID string. sl@0: * @param parent Output string buffer for the parent locale ID. sl@0: * @param parentCapacity Size of the output buffer. sl@0: * @param err A UErrorCode value. sl@0: * @return The length of the parent locale ID. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getParent(const char* localeID, sl@0: char* parent, sl@0: int32_t parentCapacity, sl@0: UErrorCode* err); sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * Gets the full name for the specified locale. sl@0: * Note: This has the effect of 'canonicalizing' the string to sl@0: * a certain extent. Upper and lower case are set as needed, sl@0: * and if the components were in 'POSIX' format they are changed to sl@0: * ICU format. It does NOT map aliased names in any way. sl@0: * See the top of this header file. sl@0: * This API strips off the keyword part, so "de_DE\@collation=phonebook" sl@0: * will become "de_DE". sl@0: * This API supports preflighting. sl@0: * sl@0: * @param localeID the locale to get the full name with sl@0: * @param name fill in buffer for the name without keywords. sl@0: * @param nameCapacity capacity of the fill in buffer. sl@0: * @param err error information if retrieving the full name failed sl@0: * @return the actual buffer size needed for the full name. If it's greater sl@0: * than nameCapacity, the returned full name will be truncated. sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getBaseName(const char* localeID, sl@0: char* name, sl@0: int32_t nameCapacity, sl@0: UErrorCode* err); sl@0: sl@0: /** sl@0: * Gets an enumeration of keywords for the specified locale. Enumeration sl@0: * must get disposed of by the client using uenum_close function. sl@0: * sl@0: * @param localeID the locale to get the variant code with sl@0: * @param status error information if retrieving the keywords failed sl@0: * @return enumeration of keywords or NULL if there are no keywords. sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE UEnumeration* U_EXPORT2 sl@0: uloc_openKeywords(const char* localeID, sl@0: UErrorCode* status); sl@0: sl@0: /** sl@0: * Get the value for a keyword. Locale name does not need to be normalized. sl@0: * sl@0: * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") sl@0: * @param keywordName name of the keyword for which we want the value. Case insensitive. sl@0: * @param buffer receiving buffer sl@0: * @param bufferCapacity capacity of receiving buffer sl@0: * @param status containing error code - buffer not big enough. sl@0: * @return the length of keyword value sl@0: * @stable ICU 2.8 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: uloc_getKeywordValue(const char* localeID, sl@0: const char* keywordName, sl@0: char* buffer, int32_t bufferCapacity, sl@0: UErrorCode* status); sl@0: sl@0: sl@0: /** sl@0: * Set the value of the specified keyword. sl@0: * NOTE: Unlike almost every other ICU function which takes a sl@0: * buffer, this function will NOT truncate the output text. If a sl@0: * BUFFER_OVERFLOW_ERROR is received, it means that the original sl@0: * buffer is untouched. This is done to prevent incorrect or possibly sl@0: * even malformed locales from being generated and used. sl@0: * sl@0: * @param keywordName name of the keyword to be set. Case insensitive. sl@0: * @param keywordValue value of the keyword to be set. If 0-length or sl@0: * NULL, will result in the keyword being removed. No error is given if sl@0: * that keyword does not exist. sl@0: * @param buffer input buffer containing locale to be modified. sl@0: * @param bufferCapacity capacity of receiving buffer sl@0: * @param status containing error code - buffer not big enough. sl@0: * @return the length needed for the buffer sl@0: * @see uloc_getKeywordValue sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: uloc_setKeywordValue(const char* keywordName, sl@0: const char* keywordValue, sl@0: char* buffer, int32_t bufferCapacity, sl@0: UErrorCode* status); sl@0: sl@0: /** sl@0: * enums for the 'outResult' parameter return value sl@0: * @see uloc_acceptLanguageFromHTTP sl@0: * @see uloc_acceptLanguage sl@0: * @draft ICU 3.2 sl@0: */ sl@0: typedef enum { sl@0: ULOC_ACCEPT_FAILED = 0, /* No exact match was found. */ sl@0: ULOC_ACCEPT_VALID = 1, /* An exact match was found. */ sl@0: ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example, sl@0: Accept list contained 'ja_JP' sl@0: which matched available locale 'ja'. */ sl@0: } UAcceptResult; sl@0: sl@0: sl@0: /** sl@0: * Based on a HTTP header from a web browser and a list of available locales, sl@0: * determine an acceptable locale for the user. sl@0: * @param result - buffer to accept the result locale sl@0: * @param resultAvailable the size of the result buffer. sl@0: * @param outResult - An out parameter that contains the fallback status sl@0: * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP. sl@0: * @param availableLocales - list of available locales to match sl@0: * @param status Error status, may be BUFFER_OVERFLOW_ERROR sl@0: * @return length needed for the locale. sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, sl@0: UAcceptResult *outResult, sl@0: const char *httpAcceptLanguage, sl@0: UEnumeration* availableLocales, sl@0: UErrorCode *status); sl@0: sl@0: /** sl@0: * Based on a list of available locales, sl@0: * determine an acceptable locale for the user. sl@0: * @param result - buffer to accept the result locale sl@0: * @param resultAvailable the size of the result buffer. sl@0: * @param outResult - An out parameter that contains the fallback status sl@0: * @param acceptList - list of acceptable languages sl@0: * @param acceptListCount - count of acceptList items sl@0: * @param availableLocales - list of available locales to match sl@0: * @param status Error status, may be BUFFER_OVERFLOW_ERROR sl@0: * @return length needed for the locale. sl@0: * @draft ICU 3.2 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: uloc_acceptLanguage(char *result, int32_t resultAvailable, sl@0: UAcceptResult *outResult, const char **acceptList, sl@0: int32_t acceptListCount, sl@0: UEnumeration* availableLocales, sl@0: UErrorCode *status); sl@0: sl@0: sl@0: #endif /*_ULOC*/ sl@0: sl@0: