📄 uloc.h
字号:
/************************************************************************ Copyright (C) 1997-2004, International Business Machines* Corporation and others. All Rights Reserved.************************************************************************ File ULOC.H** Modification History:** Date Name Description* 04/01/97 aliu Creation.* 08/22/98 stephen JDK 1.2 sync.* 12/08/98 rtg New C API for Locale* 03/30/99 damiba overhaul* 03/31/99 helena Javadoc for uloc functions.* 04/15/99 Madhu Updated Javadoc*********************************************************************************/#ifndef ULOC_H#define ULOC_H#include "unicode/utypes.h"#include "unicode/uenum.h"/** * \file * \brief C API: Locale * * <h2> ULoc C API for Locale </h2> * A <code>Locale</code> represents a specific geographical, political, * or cultural region. An operation that requires a <code>Locale</code> to perform * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code> * to tailor information for the user. For example, displaying a number * is a locale-sensitive operation--the number should be formatted * according to the customs/conventions of the user's native country, * region, or culture. In the C APIs, a locales is simply a const char string. * * <P> * You create a <code>Locale</code> with one of the three options listed below. * Each of the component is separated by '_' in the locale string. * \htmlonly<blockquote>\endhtmlonly * <pre> * \code * newLanguage * * newLanguage + newCountry * * newLanguage + newCountry + newVariant * \endcode * </pre> * \htmlonly</blockquote>\endhtmlonly * The first option is a valid <STRONG>ISO * Language Code.</STRONG> These codes are the lower-case two-letter * codes as defined by ISO-639. * You can find a full list of these codes at a number of sites, such as: * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</a> * * <P> * The second option includes an additonal <STRONG>ISO Country * Code.</STRONG> These codes are the upper-case two-letter codes * as defined by ISO-3166. * You can find a full list of these codes at a number of sites, such as: * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</a> * * <P> * The third option requires another additonal information--the * <STRONG>Variant.</STRONG> * The Variant codes are vendor and browser-specific. * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. * Where there are two variants, separate them with an underscore, and * put the most important one first. For * example, a Traditional Spanish collation might be referenced, with * "ES", "ES", "Traditional_WIN". * * <P> * Because a <code>Locale</code> is just an identifier for a region, * no validity check is performed when you specify a <code>Locale</code>. * If you want to see whether particular resources are available for the * <code>Locale</code> you asked for, you must query those resources. For * example, ask the <code>UNumberFormat</code> for the locales it supports * using its <code>getAvailable</code> method. * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular * locale, you get back the best available match, not necessarily * precisely what you asked for. For more information, look at * <code>UResourceBundle</code>. * * <P> * The <code>Locale</code> provides a number of convenient constants * that you can use to specify the commonly used * locales. For example, the following refers to a locale * for the United States: * \htmlonly<blockquote>\endhtmlonly * <pre> * \code * ULOC_US * \endcode * </pre> * \htmlonly</blockquote>\endhtmlonly * * <P> * Once you've specified a locale you can query it for information about * itself. Use <code>uloc_getCountry</code> to get the ISO Country Code and * <code>uloc_getLanguage</code> to get the ISO Language Code. You can * use <code>uloc_getDisplayCountry</code> to get the * name of the country suitable for displaying to the user. Similarly, * you can use <code>uloc_getDisplayLanguage</code> to get the name of * the language suitable for displaying to the user. Interestingly, * the <code>uloc_getDisplayXXX</code> methods are themselves locale-sensitive * and have two versions: one that uses the default locale and one * that takes a locale as an argument and displays the name or country in * a language appropriate to that locale. * * <P> * The ICU provides a number of services that perform locale-sensitive * operations. For example, the <code>unum_xxx</code> functions format * numbers, currency, or percentages in a locale-sensitive manner. * </P> * \htmlonly<blockquote>\endhtmlonly * <pre> * \code * UErrorCode success = U_ZERO_ERROR; * UNumberFormat *nf; * const char* myLocale = "fr_FR"; * * nf = unum_open( UNUM_DEFAULT, NULL, success ); * unum_close(nf); * nf = unum_open( UNUM_CURRENCY, NULL, success ); * unum_close(nf); * nf = unum_open( UNUM_PERCENT, NULL, success ); * unum_close(nf); * \endcode * </pre> * \htmlonly</blockquote>\endhtmlonly * Each of these methods has two variants; one with an explicit locale * and one without; the latter using the default locale. * \htmlonly<blockquote>\endhtmlonly * <pre> * \code * * nf = unum_open( UNUM_DEFAULT, myLocale, success ); * unum_close(nf); * nf = unum_open( UNUM_CURRENCY, myLocale, success ); * unum_close(nf); * nf = unum_open( UNUM_PERCENT, myLocale, success ); * unum_close(nf); * \endcode * </pre> * \htmlonly</blockquote>\endhtmlonly * A <code>Locale</code> is the mechanism for identifying the kind of services * (<code>UNumberFormat</code>) that you would like to get. The locale is * <STRONG>just</STRONG> a mechanism for identifying these services. * * <P> * Each international serivce that performs locale-sensitive operations * allows you * to get all the available objects of that type. You can sift * through these objects by language, country, or variant, * and use the display names to present a menu to the user. * For example, you can create a menu of all the collation objects * suitable for a given language. Such classes implement these * three class methods: * \htmlonly<blockquote>\endhtmlonly * <pre> * \code * const char* uloc_getAvailable(int32_t index); * int32_t uloc_countAvailable(); * int32_t * uloc_getDisplayName(const char* localeID, * const char* inLocaleID, * UChar* result, * int32_t maxResultSize, * UErrorCode* err); * * \endcode * </pre> * \htmlonly</blockquote>\endhtmlonly * <P> * Concerning POSIX/RFC1766 Locale IDs, * the getLanguage/getCountry/getVariant/getName functions do understand * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT * and if there is not an ICU-stype variant, uloc_getVariant() for example * will return the one listed after the \@at sign. As well, the hyphen * "-" is recognized as a country/variant separator similarly to RFC1766. * So for example, "en-us" will be interpreted as en_US. * As a result, uloc_getName() is far from a no-op, and will have the * effect of converting POSIX/RFC1766 IDs into ICU form, although it does * NOT map any of the actual codes (i.e. russian->ru) in any way. * Applications should call uloc_getName() at the point where a locale ID * is coming from an external source (user entry, OS, web browser) * and pass the resulting string to other ICU functions. For example, * don't use de-de\@EURO as an argument to resourcebundle. * * @see UResourceBundle *//** Useful constant for this language. @stable ICU 2.0 */#define ULOC_CHINESE "zh"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_ENGLISH "en"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_FRENCH "fr"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_GERMAN "de"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_ITALIAN "it"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_JAPANESE "ja"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_KOREAN "ko"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_SIMPLIFIED_CHINESE "zh_CN"/** Useful constant for this language. @stable ICU 2.0 */#define ULOC_TRADITIONAL_CHINESE "zh_TW"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_CANADA "en_CA"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_CANADA_FRENCH "fr_CA"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_CHINA "zh_CN"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_PRC "zh_CN"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_FRANCE "fr_FR"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_GERMANY "de_DE"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_ITALY "it_IT"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_JAPAN "ja_JP"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_KOREA "ko_KR"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_TAIWAN "zh_TW"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_UK "en_GB"/** Useful constant for this country/region. @stable ICU 2.0 */#define ULOC_US "en_US"/** * Useful constant for the maximum size of the language part of a locale ID. * (including the terminating NULL). * @stable ICU 2.0 */#define ULOC_LANG_CAPACITY 12/** * Useful constant for the maximum size of the country part of a locale ID * (including the terminating NULL). * @stable ICU 2.0 */#define ULOC_COUNTRY_CAPACITY 4/** * Useful constant for the maximum size of the whole locale ID * (including the terminating NULL). * @stable ICU 2.0 */#define ULOC_FULLNAME_CAPACITY 56#ifndef U_HIDE_DRAFT_API/** * Useful constant for the maximum size of the script part of a locale ID * (including the terminating NULL). * @draft ICU 2.8 */#define ULOC_SCRIPT_CAPACITY 6/** * Useful constant for the maximum size of keywords in a locale * @draft ICU 2.8 */#define ULOC_KEYWORDS_CAPACITY 50/** * Useful constant for the maximum size of keywords in a locale * @draft ICU 2.8 */#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100/** * Character separating keywords from the locale string * different for EBCDIC - TODO * @draft ICU 2.8 */#define ULOC_KEYWORD_SEPARATOR '@'/** * Character for assigning value to a keyword * @draft ICU 2.8 */#define ULOC_KEYWORD_ASSIGN '='/** * Character separating keywords * @draft ICU 2.8 */#define ULOC_KEYWORD_ITEM_SEPARATOR ';'#endif /*U_HIDE_DRAFT_API*//** * Constants for *_getLocale()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -