1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/locid.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,765 @@
1.4 +/*
1.5 +******************************************************************************
1.6 +*
1.7 +* Copyright (C) 1996-2005, International Business Machines
1.8 +* Corporation and others. All Rights Reserved.
1.9 +*
1.10 +******************************************************************************
1.11 +*
1.12 +* File locid.h
1.13 +*
1.14 +* Created by: Helena Shih
1.15 +*
1.16 +* Modification History:
1.17 +*
1.18 +* Date Name Description
1.19 +* 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to
1.20 +* get and set it.
1.21 +* 04/02/97 aliu Made operator!= inline; fixed return value of getName().
1.22 +* 04/15/97 aliu Cleanup for AIX/Win32.
1.23 +* 04/24/97 aliu Numerous changes per code review.
1.24 +* 08/18/98 stephen Added tokenizeString(),changed getDisplayName()
1.25 +* 09/08/98 stephen Moved definition of kEmptyString for Mac Port
1.26 +* 11/09/99 weiv Added const char * getName() const;
1.27 +* 04/12/00 srl removing unicodestring api's and cached hash code
1.28 +* 08/10/01 grhoten Change the static Locales to accessor functions
1.29 +******************************************************************************
1.30 +*/
1.31 +
1.32 +#ifndef LOCID_H
1.33 +#define LOCID_H
1.34 +
1.35 +#include "unicode/utypes.h"
1.36 +#include "unicode/uobject.h"
1.37 +#include "unicode/unistr.h"
1.38 +#include "unicode/putil.h"
1.39 +#include "unicode/uloc.h"
1.40 +#include "unicode/strenum.h"
1.41 +
1.42 +/**
1.43 + * \file
1.44 + * \brief C++ API: Locale ID object.
1.45 + */
1.46 +
1.47 +/**
1.48 + * A <code>Locale</code> object represents a specific geographical, political,
1.49 + * or cultural region. An operation that requires a <code>Locale</code> to perform
1.50 + * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>
1.51 + * to tailor information for the user. For example, displaying a number
1.52 + * is a locale-sensitive operation--the number should be formatted
1.53 + * according to the customs/conventions of the user's native country,
1.54 + * region, or culture.
1.55 + *
1.56 + * The Locale class is not suitable for subclassing.
1.57 + *
1.58 + * <P>
1.59 + * You can create a <code>Locale</code> object using the constructor in
1.60 + * this class:
1.61 + * \htmlonly<blockquote>\endhtmlonly
1.62 + * <pre>
1.63 + * . Locale( const char* language,
1.64 + * . const char* country,
1.65 + * . const char* variant);
1.66 + * </pre>
1.67 + * \htmlonly</blockquote>\endhtmlonly
1.68 + * The first argument to the constructors is a valid <STRONG>ISO
1.69 + * Language Code.</STRONG> These codes are the lower-case two-letter
1.70 + * codes as defined by ISO-639.
1.71 + * You can find a full list of these codes at:
1.72 + * <BR><a href ="http://www.loc.gov/standards/iso639-2/">
1.73 + * http://www.loc.gov/standards/iso639-2/</a>
1.74 + *
1.75 + * <P>
1.76 + * The second argument to the constructors is a valid <STRONG>ISO Country
1.77 + * Code.</STRONG> These codes are the upper-case two-letter codes
1.78 + * as defined by ISO-3166.
1.79 + * You can find a full list of these codes at a number of sites, such as:
1.80 + * <BR><a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html">
1.81 + * http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html</a>
1.82 + *
1.83 + * <P>
1.84 + * The third constructor requires a third argument--the <STRONG>Variant.</STRONG>
1.85 + * The Variant codes are vendor and browser-specific.
1.86 + * For example, use REVISED for a langauge's revised script orthography, and POSIX for POSIX.
1.87 + * Where there are two variants, separate them with an underscore, and
1.88 + * put the most important one first. For
1.89 + * example, a Traditional Spanish collation might be referenced, with
1.90 + * "ES", "ES", "Traditional_POSIX".
1.91 + *
1.92 + * <P>
1.93 + * Because a <code>Locale</code> object is just an identifier for a region,
1.94 + * no validity check is performed when you construct a <code>Locale</code>.
1.95 + * If you want to see whether particular resources are available for the
1.96 + * <code>Locale</code> you construct, you must query those resources. For
1.97 + * example, ask the <code>NumberFormat</code> for the locales it supports
1.98 + * using its <code>getAvailableLocales</code> method.
1.99 + * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular
1.100 + * locale, you get back the best available match, not necessarily
1.101 + * precisely what you asked for. For more information, look at
1.102 + * <code>ResourceBundle</code>.
1.103 + *
1.104 + * <P>
1.105 + * The <code>Locale</code> class provides a number of convenient constants
1.106 + * that you can use to create <code>Locale</code> objects for commonly used
1.107 + * locales. For example, the following refers to a <code>Locale</code> object
1.108 + * for the United States:
1.109 + * \htmlonly<blockquote>\endhtmlonly
1.110 + * <pre>
1.111 + * Locale::getUS()
1.112 + * </pre>
1.113 + * \htmlonly</blockquote>\endhtmlonly
1.114 + *
1.115 + * <P>
1.116 + * Once you've created a <code>Locale</code> you can query it for information about
1.117 + * itself. Use <code>getCountry</code> to get the ISO Country Code and
1.118 + * <code>getLanguage</code> to get the ISO Language Code. You can
1.119 + * use <code>getDisplayCountry</code> to get the
1.120 + * name of the country suitable for displaying to the user. Similarly,
1.121 + * you can use <code>getDisplayLanguage</code> to get the name of
1.122 + * the language suitable for displaying to the user. Interestingly,
1.123 + * the <code>getDisplayXXX</code> methods are themselves locale-sensitive
1.124 + * and have two versions: one that uses the default locale and one
1.125 + * that takes a locale as an argument and displays the name or country in
1.126 + * a language appropriate to that locale.
1.127 + *
1.128 + * <P>
1.129 + * ICU provides a number of classes that perform locale-sensitive
1.130 + * operations. For example, the <code>NumberFormat</code> class formats
1.131 + * numbers, currency, or percentages in a locale-sensitive manner. Classes
1.132 + * such as <code>NumberFormat</code> have a number of convenience methods
1.133 + * for creating a default object of that type. For example, the
1.134 + * <code>NumberFormat</code> class provides these three convenience methods
1.135 + * for creating a default <code>NumberFormat</code> object:
1.136 + * \htmlonly<blockquote>\endhtmlonly
1.137 + * <pre>
1.138 + * UErrorCode success = U_ZERO_ERROR;
1.139 + * Locale myLocale;
1.140 + * NumberFormat *nf;
1.141 + *
1.142 + * nf = NumberFormat::createInstance( success ); delete nf;
1.143 + * nf = NumberFormat::createCurrencyInstance( success ); delete nf;
1.144 + * nf = NumberFormat::createPercentInstance( success ); delete nf;
1.145 + * </pre>
1.146 + * \htmlonly</blockquote>\endhtmlonly
1.147 + * Each of these methods has two variants; one with an explicit locale
1.148 + * and one without; the latter using the default locale.
1.149 + * \htmlonly<blockquote>\endhtmlonly
1.150 + * <pre>
1.151 + * nf = NumberFormat::createInstance( myLocale, success ); delete nf;
1.152 + * nf = NumberFormat::createCurrencyInstance( myLocale, success ); delete nf;
1.153 + * nf = NumberFormat::createPercentInstance( myLocale, success ); delete nf;
1.154 + * </pre>
1.155 + * \htmlonly</blockquote>\endhtmlonly
1.156 + * A <code>Locale</code> is the mechanism for identifying the kind of object
1.157 + * (<code>NumberFormat</code>) that you would like to get. The locale is
1.158 + * <STRONG>just</STRONG> a mechanism for identifying objects,
1.159 + * <STRONG>not</STRONG> a container for the objects themselves.
1.160 + *
1.161 + * <P>
1.162 + * Each class that performs locale-sensitive operations allows you
1.163 + * to get all the available objects of that type. You can sift
1.164 + * through these objects by language, country, or variant,
1.165 + * and use the display names to present a menu to the user.
1.166 + * For example, you can create a menu of all the collation objects
1.167 + * suitable for a given language. Such classes implement these
1.168 + * three class methods:
1.169 + * \htmlonly<blockquote>\endhtmlonly
1.170 + * <pre>
1.171 + * static Locale* getAvailableLocales(int32_t& numLocales)
1.172 + * static UnicodeString& getDisplayName(const Locale& objectLocale,
1.173 + * const Locale& displayLocale,
1.174 + * UnicodeString& displayName)
1.175 + * static UnicodeString& getDisplayName(const Locale& objectLocale,
1.176 + * UnicodeString& displayName)
1.177 + * </pre>
1.178 + * \htmlonly</blockquote>\endhtmlonly
1.179 + *
1.180 + * @stable ICU 2.0
1.181 + * @see ResourceBundle
1.182 + */
1.183 +U_NAMESPACE_BEGIN
1.184 +class U_COMMON_API Locale : public UObject {
1.185 +public:
1.186 + /** Useful constant for this language. @stable ICU 2.0 */
1.187 + static const Locale &U_EXPORT2 getEnglish(void);
1.188 + /** Useful constant for this language. @stable ICU 2.0 */
1.189 + static const Locale &U_EXPORT2 getFrench(void);
1.190 + /** Useful constant for this language. @stable ICU 2.0 */
1.191 + static const Locale &U_EXPORT2 getGerman(void);
1.192 + /** Useful constant for this language. @stable ICU 2.0 */
1.193 + static const Locale &U_EXPORT2 getItalian(void);
1.194 + /** Useful constant for this language. @stable ICU 2.0 */
1.195 + static const Locale &U_EXPORT2 getJapanese(void);
1.196 + /** Useful constant for this language. @stable ICU 2.0 */
1.197 + static const Locale &U_EXPORT2 getKorean(void);
1.198 + /** Useful constant for this language. @stable ICU 2.0 */
1.199 + static const Locale &U_EXPORT2 getChinese(void);
1.200 + /** Useful constant for this language. @stable ICU 2.0 */
1.201 + static const Locale &U_EXPORT2 getSimplifiedChinese(void);
1.202 + /** Useful constant for this language. @stable ICU 2.0 */
1.203 + static const Locale &U_EXPORT2 getTraditionalChinese(void);
1.204 +
1.205 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.206 + static const Locale &U_EXPORT2 getFrance(void);
1.207 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.208 + static const Locale &U_EXPORT2 getGermany(void);
1.209 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.210 + static const Locale &U_EXPORT2 getItaly(void);
1.211 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.212 + static const Locale &U_EXPORT2 getJapan(void);
1.213 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.214 + static const Locale &U_EXPORT2 getKorea(void);
1.215 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.216 + static const Locale &U_EXPORT2 getChina(void);
1.217 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.218 + static const Locale &U_EXPORT2 getPRC(void);
1.219 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.220 + static const Locale &U_EXPORT2 getTaiwan(void);
1.221 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.222 + static const Locale &U_EXPORT2 getUK(void);
1.223 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.224 + static const Locale &U_EXPORT2 getUS(void);
1.225 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.226 + static const Locale &U_EXPORT2 getCanada(void);
1.227 + /** Useful constant for this country/region. @stable ICU 2.0 */
1.228 + static const Locale &U_EXPORT2 getCanadaFrench(void);
1.229 +
1.230 +
1.231 + /**
1.232 + * Construct a default locale object, a Locale for the default locale ID.
1.233 + *
1.234 + * @see getDefault
1.235 + * @see uloc_getDefault
1.236 + * @stable ICU 2.0
1.237 + */
1.238 + Locale();
1.239 +
1.240 + /**
1.241 + * Construct a locale from language, country, variant.
1.242 + * If an error occurs, then the constructed object will be "bogus"
1.243 + * (isBogus() will return TRUE).
1.244 + *
1.245 + * @param language Lowercase two-letter or three-letter ISO-639 code.
1.246 + * This parameter can instead be an ICU style C locale (e.g. "en_US"),
1.247 + * but the other parameters must not be used.
1.248 + * This parameter can be NULL; if so,
1.249 + * the locale is initialized to match the current default locale.
1.250 + * (This is the same as using the default constructor.)
1.251 + * Please note: The Java Locale class does NOT accept the form
1.252 + * 'new Locale("en_US")' but only 'new Locale("en","US")'
1.253 + *
1.254 + * @param country Uppercase two-letter ISO-3166 code. (optional)
1.255 + * @param variant Uppercase vendor and browser specific code. See class
1.256 + * description. (optional)
1.257 + * @param keywordsAndValues A string consisting of keyword/values pairs, such as
1.258 + * "collation=phonebook;currency=euro"
1.259 + *
1.260 + * @see getDefault
1.261 + * @see uloc_getDefault
1.262 + * @stable ICU 2.0
1.263 + */
1.264 + Locale( const char * language,
1.265 + const char * country = 0,
1.266 + const char * variant = 0,
1.267 + const char * keywordsAndValues = 0);
1.268 +
1.269 + /**
1.270 + * Initializes a Locale object from another Locale object.
1.271 + *
1.272 + * @param other The Locale object being copied in.
1.273 + * @stable ICU 2.0
1.274 + */
1.275 + Locale(const Locale& other);
1.276 +
1.277 +
1.278 + /**
1.279 + * Destructor
1.280 + * @stable ICU 2.0
1.281 + */
1.282 + virtual ~Locale() ;
1.283 +
1.284 + /**
1.285 + * Replaces the entire contents of *this with the specified value.
1.286 + *
1.287 + * @param other The Locale object being copied in.
1.288 + * @return *this
1.289 + * @stable ICU 2.0
1.290 + */
1.291 + Locale& operator=(const Locale& other);
1.292 +
1.293 + /**
1.294 + * Checks if two locale keys are the same.
1.295 + *
1.296 + * @param other The locale key object to be compared with this.
1.297 + * @return True if the two locale keys are the same, false otherwise.
1.298 + * @stable ICU 2.0
1.299 + */
1.300 + UBool operator==(const Locale& other) const;
1.301 +
1.302 + /**
1.303 + * Checks if two locale keys are not the same.
1.304 + *
1.305 + * @param other The locale key object to be compared with this.
1.306 + * @return True if the two locale keys are not the same, false
1.307 + * otherwise.
1.308 + * @stable ICU 2.0
1.309 + */
1.310 + UBool operator!=(const Locale& other) const;
1.311 +
1.312 + /**
1.313 + * Clone this object.
1.314 + * Clones can be used concurrently in multiple threads.
1.315 + * If an error occurs, then NULL is returned.
1.316 + * The caller must delete the clone.
1.317 + *
1.318 + * @return a clone of this object
1.319 + *
1.320 + * @see getDynamicClassID
1.321 + * @stable ICU 2.8
1.322 + */
1.323 + Locale *clone() const;
1.324 +
1.325 + /**
1.326 + * Common methods of getting the current default Locale. Used for the
1.327 + * presentation: menus, dialogs, etc. Generally set once when your applet or
1.328 + * application is initialized, then never reset. (If you do reset the
1.329 + * default locale, you probably want to reload your GUI, so that the change
1.330 + * is reflected in your interface.)
1.331 + *
1.332 + * More advanced programs will allow users to use different locales for
1.333 + * different fields, e.g. in a spreadsheet.
1.334 + *
1.335 + * Note that the initial setting will match the host system.
1.336 + * @return a reference to the Locale object for the default locale ID
1.337 + * @system
1.338 + * @stable ICU 2.0
1.339 + */
1.340 + static const Locale& U_EXPORT2 getDefault(void);
1.341 +
1.342 + /**
1.343 + * Sets the default. Normally set once at the beginning of a process,
1.344 + * then never reset.
1.345 + * setDefault() only changes ICU's default locale ID, <strong>not</strong>
1.346 + * the default locale ID of the runtime environment.
1.347 + *
1.348 + * @param newLocale Locale to set to. If NULL, set to the value obtained
1.349 + * from the runtime environement.
1.350 + * @param success The error code.
1.351 + * @system
1.352 + * @stable ICU 2.0
1.353 + */
1.354 + static void U_EXPORT2 setDefault(const Locale& newLocale,
1.355 + UErrorCode& success);
1.356 +
1.357 + /**
1.358 + * Creates a locale which has had minimal canonicalization
1.359 + * as per uloc_getName().
1.360 + * @param name The name to create from. If name is null,
1.361 + * the default Locale is used.
1.362 + * @return new locale object
1.363 + * @stable ICU 2.0
1.364 + * @see uloc_getName
1.365 + */
1.366 + static Locale U_EXPORT2 createFromName(const char *name);
1.367 +
1.368 + /**
1.369 + * Creates a locale from the given string after canonicalizing
1.370 + * the string by calling uloc_canonicalize().
1.371 + * @param name the locale ID to create from. Must not be NULL.
1.372 + * @return a new locale object corresponding to the given name
1.373 + * @draft ICU 3.0
1.374 + * @see uloc_canonicalize
1.375 + */
1.376 + static Locale U_EXPORT2 createCanonical(const char* name);
1.377 +
1.378 + /**
1.379 + * Returns the locale's ISO-639 language code.
1.380 + * @return An alias to the code
1.381 + * @stable ICU 2.0
1.382 + */
1.383 + inline const char * getLanguage( ) const;
1.384 +
1.385 + /**
1.386 + * Returns the locale's ISO-15924 abbreviation script code.
1.387 + * @return An alias to the code
1.388 + * @see uscript_getShortName
1.389 + * @see uscript_getCode
1.390 + * @stable ICU 2.8
1.391 + */
1.392 + inline const char * getScript( ) const;
1.393 +
1.394 + /**
1.395 + * Returns the locale's ISO-3166 country code.
1.396 + * @return An alias to the code
1.397 + * @stable ICU 2.0
1.398 + */
1.399 + inline const char * getCountry( ) const;
1.400 +
1.401 + /**
1.402 + * Returns the locale's variant code.
1.403 + * @return An alias to the code
1.404 + * @stable ICU 2.0
1.405 + */
1.406 + inline const char * getVariant( ) const;
1.407 +
1.408 + /**
1.409 + * Returns the programmatic name of the entire locale, with the language,
1.410 + * country and variant separated by underbars. If a field is missing, up
1.411 + * to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN",
1.412 + * "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO"
1.413 + * @return A pointer to "name".
1.414 + * @stable ICU 2.0
1.415 + */
1.416 + inline const char * getName() const;
1.417 +
1.418 + /**
1.419 + * Returns the programmatic name of the entire locale as getName would return,
1.420 + * but without keywords.
1.421 + * @return A pointer to "name".
1.422 + * @see getName
1.423 + * @stable ICU 2.8
1.424 + */
1.425 + const char * getBaseName() const;
1.426 +
1.427 +
1.428 + /**
1.429 + * Gets the list of keywords for the specified locale.
1.430 + *
1.431 + * @return pointer to StringEnumeration class. Client must dispose of it by calling delete.
1.432 + * @param status Returns any error information while performing this operation.
1.433 + * @stable ICU 2.8
1.434 + */
1.435 + StringEnumeration * createKeywords(UErrorCode &status) const;
1.436 +
1.437 + /**
1.438 + * Get the value for a keyword.
1.439 + *
1.440 + * @param keywordName name of the keyword for which we want the value. Case insensitive.
1.441 + * @param status Returns any error information while performing this operation.
1.442 + * @param buffer The buffer to receive the keyword value.
1.443 + * @param bufferCapacity The capacity of receiving buffer
1.444 + * @return the length of keyword value
1.445 + *
1.446 + * @stable ICU 2.8
1.447 + */
1.448 + int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
1.449 +
1.450 + /**
1.451 + * returns the locale's three-letter language code, as specified
1.452 + * in ISO draft standard ISO-639-2..
1.453 + * @return An alias to the code, or NULL
1.454 + * @stable ICU 2.0
1.455 + */
1.456 + const char * getISO3Language() const;
1.457 +
1.458 + /**
1.459 + * Fills in "name" with the locale's three-letter ISO-3166 country code.
1.460 + * @return An alias to the code, or NULL
1.461 + * @stable ICU 2.0
1.462 + */
1.463 + const char * getISO3Country() const;
1.464 +
1.465 + /**
1.466 + * Returns the Windows LCID value corresponding to this locale.
1.467 + * This value is stored in the resource data for the locale as a one-to-four-digit
1.468 + * hexadecimal number. If the resource is missing, in the wrong format, or
1.469 + * there is no Windows LCID value that corresponds to this locale, returns 0.
1.470 + * @stable ICU 2.0
1.471 + */
1.472 + uint32_t getLCID(void) const;
1.473 +
1.474 + /**
1.475 + * Fills in "dispLang" with the name of this locale's language in a format suitable for
1.476 + * user display in the default locale. For example, if the locale's language code is
1.477 + * "fr" and the default locale's language code is "en", this function would set
1.478 + * dispLang to "French".
1.479 + * @param dispLang Receives the language's display name.
1.480 + * @return A reference to "dispLang".
1.481 + * @stable ICU 2.0
1.482 + */
1.483 + UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
1.484 +
1.485 + /**
1.486 + * Fills in "dispLang" with the name of this locale's language in a format suitable for
1.487 + * user display in the locale specified by "displayLocale". For example, if the locale's
1.488 + * language code is "en" and displayLocale's language code is "fr", this function would set
1.489 + * dispLang to "Anglais".
1.490 + * @param displayLocale Specifies the locale to be used to display the name. In other words,
1.491 + * if the locale's language code is "en", passing Locale::getFrench() for
1.492 + * displayLocale would result in "Anglais", while passing Locale::getGerman()
1.493 + * for displayLocale would result in "Englisch".
1.494 + * @param dispLang Receives the language's display name.
1.495 + * @return A reference to "dispLang".
1.496 + * @stable ICU 2.0
1.497 + */
1.498 + UnicodeString& getDisplayLanguage( const Locale& displayLocale,
1.499 + UnicodeString& dispLang) const;
1.500 +
1.501 + /**
1.502 + * Fills in "dispScript" with the name of this locale's script in a format suitable
1.503 + * for user display in the default locale. For example, if the locale's script code
1.504 + * is "LATN" and the default locale's language code is "en", this function would set
1.505 + * dispScript to "Latin".
1.506 + * @param dispScript Receives the scripts's display name.
1.507 + * @return A reference to "dispScript".
1.508 + * @stable ICU 2.8
1.509 + */
1.510 + UnicodeString& getDisplayScript( UnicodeString& dispScript) const;
1.511 +
1.512 + /**
1.513 + * Fills in "dispScript" with the name of this locale's country in a format suitable
1.514 + * for user display in the locale specified by "displayLocale". For example, if the locale's
1.515 + * script code is "LATN" and displayLocale's language code is "en", this function would set
1.516 + * dispScript to "Latin".
1.517 + * @param displayLocale Specifies the locale to be used to display the name. In other
1.518 + * words, if the locale's script code is "LATN", passing
1.519 + * Locale::getFrench() for displayLocale would result in "", while
1.520 + * passing Locale::getGerman() for displayLocale would result in
1.521 + * "".
1.522 + * @param dispScript Receives the scripts's display name.
1.523 + * @return A reference to "dispScript".
1.524 + * @stable ICU 2.8
1.525 + */
1.526 + UnicodeString& getDisplayScript( const Locale& displayLocale,
1.527 + UnicodeString& dispScript) const;
1.528 +
1.529 + /**
1.530 + * Fills in "dispCountry" with the name of this locale's country in a format suitable
1.531 + * for user display in the default locale. For example, if the locale's country code
1.532 + * is "FR" and the default locale's language code is "en", this function would set
1.533 + * dispCountry to "France".
1.534 + * @param dispCountry Receives the country's display name.
1.535 + * @return A reference to "dispCountry".
1.536 + * @stable ICU 2.0
1.537 + */
1.538 + UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
1.539 +
1.540 + /**
1.541 + * Fills in "dispCountry" with the name of this locale's country in a format suitable
1.542 + * for user display in the locale specified by "displayLocale". For example, if the locale's
1.543 + * country code is "US" and displayLocale's language code is "fr", this function would set
1.544 + * dispCountry to "États-Unis".
1.545 + * @param displayLocale Specifies the locale to be used to display the name. In other
1.546 + * words, if the locale's country code is "US", passing
1.547 + * Locale::getFrench() for displayLocale would result in "États-Unis", while
1.548 + * passing Locale::getGerman() for displayLocale would result in
1.549 + * "Vereinigte Staaten".
1.550 + * @param dispCountry Receives the country's display name.
1.551 + * @return A reference to "dispCountry".
1.552 + * @stable ICU 2.0
1.553 + */
1.554 + UnicodeString& getDisplayCountry( const Locale& displayLocale,
1.555 + UnicodeString& dispCountry) const;
1.556 +
1.557 + /**
1.558 + * Fills in "dispVar" with the name of this locale's variant code in a format suitable
1.559 + * for user display in the default locale.
1.560 + * @param dispVar Receives the variant's name.
1.561 + * @return A reference to "dispVar".
1.562 + * @stable ICU 2.0
1.563 + */
1.564 + UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
1.565 +
1.566 + /**
1.567 + * Fills in "dispVar" with the name of this locale's variant code in a format
1.568 + * suitable for user display in the locale specified by "displayLocale".
1.569 + * @param displayLocale Specifies the locale to be used to display the name.
1.570 + * @param dispVar Receives the variant's display name.
1.571 + * @return A reference to "dispVar".
1.572 + * @stable ICU 2.0
1.573 + */
1.574 + UnicodeString& getDisplayVariant( const Locale& displayLocale,
1.575 + UnicodeString& dispVar) const;
1.576 +
1.577 + /**
1.578 + * Fills in "name" with the name of this locale in a format suitable for user display
1.579 + * in the default locale. This function uses getDisplayLanguage(), getDisplayCountry(),
1.580 + * and getDisplayVariant() to do its work, and outputs the display name in the format
1.581 + * "language (country[,variant])". For example, if the default locale is en_US, then
1.582 + * fr_FR's display name would be "French (France)", and es_MX_Traditional's display name
1.583 + * would be "Spanish (Mexico,Traditional)".
1.584 + * @param name Receives the locale's display name.
1.585 + * @return A reference to "name".
1.586 + * @stable ICU 2.0
1.587 + */
1.588 + UnicodeString& getDisplayName( UnicodeString& name) const;
1.589 +
1.590 + /**
1.591 + * Fills in "name" with the name of this locale in a format suitable for user display
1.592 + * in the locale specfied by "displayLocale". This function uses getDisplayLanguage(),
1.593 + * getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display
1.594 + * name in the format "language (country[,variant])". For example, if displayLocale is
1.595 + * fr_FR, then en_US's display name would be "Anglais (États-Unis)", and no_NO_NY's
1.596 + * display name would be "norvégien (Norvège,NY)".
1.597 + * @param displayLocale Specifies the locale to be used to display the name.
1.598 + * @param name Receives the locale's display name.
1.599 + * @return A reference to "name".
1.600 + * @stable ICU 2.0
1.601 + */
1.602 + UnicodeString& getDisplayName( const Locale& displayLocale,
1.603 + UnicodeString& name) const;
1.604 +
1.605 + /**
1.606 + * Generates a hash code for the locale.
1.607 + * @stable ICU 2.0
1.608 + */
1.609 + int32_t hashCode(void) const;
1.610 +
1.611 + /**
1.612 + * Sets the locale to bogus
1.613 + * A bogus locale represents a non-existing locale associated
1.614 + * with services that can be instantiated from non-locale data
1.615 + * in addition to locale (for example, collation can be
1.616 + * instantiated from a locale and from a rule set).
1.617 + * @stable ICU 2.1
1.618 + */
1.619 + void setToBogus();
1.620 +
1.621 + /**
1.622 + * Gets the bogus state. Locale object can be bogus if it doesn't exist
1.623 + * @return FALSE if it is a real locale, TRUE if it is a bogus locale
1.624 + * @stable ICU 2.1
1.625 + */
1.626 + UBool isBogus(void) const;
1.627 +
1.628 + /**
1.629 + * Returns a list of all installed locales.
1.630 + * @param count Receives the number of locales in the list.
1.631 + * @return A pointer to an array of Locale objects. This array is the list
1.632 + * of all locales with installed resource files. The called does NOT
1.633 + * get ownership of this list, and must NOT delete it.
1.634 + * @stable ICU 2.0
1.635 + */
1.636 + static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
1.637 +
1.638 + /**
1.639 + * Gets a list of all available 2-letter country codes defined in ISO 639. This is a
1.640 + * pointer to an array of pointers to arrays of char. All of these pointers are
1.641 + * owned by ICU-- do not delete them, and do not write through them. The array is
1.642 + * terminated with a null pointer.
1.643 + * @return a list of all available country codes
1.644 + * @stable ICU 2.0
1.645 + */
1.646 + static const char* const* U_EXPORT2 getISOCountries();
1.647 +
1.648 + /**
1.649 + * Gets a list of all available language codes defined in ISO 639. This is a pointer
1.650 + * to an array of pointers to arrays of char. All of these pointers are owned
1.651 + * by ICU-- do not delete them, and do not write through them. The array is
1.652 + * terminated with a null pointer.
1.653 + * @return a list of all available language codes
1.654 + * @stable ICU 2.0
1.655 + */
1.656 + static const char* const* U_EXPORT2 getISOLanguages();
1.657 +
1.658 + /**
1.659 + * ICU "poor man's RTTI", returns a UClassID for this class.
1.660 + *
1.661 + * @stable ICU 2.2
1.662 + */
1.663 + static UClassID U_EXPORT2 getStaticClassID();
1.664 +
1.665 + /**
1.666 + * ICU "poor man's RTTI", returns a UClassID for the actual class.
1.667 + *
1.668 + * @stable ICU 2.2
1.669 + */
1.670 + virtual UClassID getDynamicClassID() const;
1.671 +
1.672 +protected: /* only protected for testing purposes. DO NOT USE. */
1.673 + /**
1.674 + * Set this from a single POSIX style locale string.
1.675 + * @internal
1.676 + */
1.677 + void setFromPOSIXID(const char *posixID);
1.678 +
1.679 +private:
1.680 + /**
1.681 + * Initialize the locale object with a new name.
1.682 + * Was deprecated - used in implementation - moved internal
1.683 + *
1.684 + * @param cLocaleID The new locale name.
1.685 + */
1.686 + Locale& init(const char* cLocaleID, UBool canonicalize);
1.687 +
1.688 + /*
1.689 + * Internal constructor to allow construction of a locale object with
1.690 + * NO side effects. (Default constructor tries to get
1.691 + * the default locale.)
1.692 + */
1.693 + enum ELocaleType {
1.694 + eBOGUS
1.695 + };
1.696 + Locale(ELocaleType);
1.697 +
1.698 + /**
1.699 + * Initialize the locale cache for commonly used locales
1.700 + */
1.701 + static Locale *getLocaleCache(void);
1.702 +
1.703 + char language[ULOC_LANG_CAPACITY];
1.704 + char script[ULOC_SCRIPT_CAPACITY];
1.705 + char country[ULOC_COUNTRY_CAPACITY];
1.706 + int32_t variantBegin;
1.707 + char* fullName;
1.708 + char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
1.709 + // name without keywords
1.710 + char* baseName;
1.711 + char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
1.712 +
1.713 + UBool fIsBogus;
1.714 +
1.715 + static const Locale &getLocale(int locid);
1.716 +
1.717 + /**
1.718 + * A friend to allow the default locale to be set by either the C or C++ API.
1.719 + * @internal
1.720 + */
1.721 + friend void locale_set_default_internal(const char *);
1.722 +};
1.723 +
1.724 +inline UBool
1.725 +Locale::operator!=(const Locale& other) const
1.726 +{
1.727 + return !operator==(other);
1.728 +}
1.729 +
1.730 +inline const char *
1.731 +Locale::getCountry() const
1.732 +{
1.733 + return country;
1.734 +}
1.735 +
1.736 +inline const char *
1.737 +Locale::getLanguage() const
1.738 +{
1.739 + return language;
1.740 +}
1.741 +
1.742 +inline const char *
1.743 +Locale::getScript() const
1.744 +{
1.745 + return script;
1.746 +}
1.747 +
1.748 +inline const char *
1.749 +Locale::getVariant() const
1.750 +{
1.751 + return &fullName[variantBegin];
1.752 +}
1.753 +
1.754 +inline const char *
1.755 +Locale::getName() const
1.756 +{
1.757 + return fullName;
1.758 +}
1.759 +
1.760 +inline UBool
1.761 +Locale::isBogus(void) const {
1.762 + return fIsBogus;
1.763 +}
1.764 +
1.765 +U_NAMESPACE_END
1.766 +
1.767 +#endif
1.768 +