1999-12-28 23:39:02 +00:00
|
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
2004-05-18 22:01:41 +00:00
|
|
|
|
* Copyright (C) 1996-2004, International Business Machines
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
|
|
|
|
* File locid.h
|
|
|
|
|
*
|
|
|
|
|
* Created by: Helena Shih
|
|
|
|
|
*
|
|
|
|
|
* Modification History:
|
|
|
|
|
*
|
|
|
|
|
* Date Name Description
|
|
|
|
|
* 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to
|
|
|
|
|
* get and set it.
|
|
|
|
|
* 04/02/97 aliu Made operator!= inline; fixed return value of getName().
|
|
|
|
|
* 04/15/97 aliu Cleanup for AIX/Win32.
|
|
|
|
|
* 04/24/97 aliu Numerous changes per code review.
|
|
|
|
|
* 08/18/98 stephen Added tokenizeString(),changed getDisplayName()
|
|
|
|
|
* 09/08/98 stephen Moved definition of kEmptyString for Mac Port
|
2001-03-21 20:44:20 +00:00
|
|
|
|
* 11/09/99 weiv Added const char * getName() const;
|
2000-04-15 21:19:44 +00:00
|
|
|
|
* 04/12/00 srl removing unicodestring api's and cached hash code
|
2001-08-10 22:36:26 +00:00
|
|
|
|
* 08/10/01 grhoten Change the static Locales to accessor functions
|
2001-03-21 20:44:20 +00:00
|
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef LOCID_H
|
|
|
|
|
#define LOCID_H
|
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
#include "unicode/uobject.h"
|
|
|
|
|
#include "unicode/unistr.h"
|
2000-09-20 18:09:07 +00:00
|
|
|
|
#include "unicode/putil.h"
|
2002-02-14 22:28:05 +00:00
|
|
|
|
#include "unicode/uloc.h"
|
2003-10-15 05:30:32 +00:00
|
|
|
|
#include "unicode/strenum.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file
|
|
|
|
|
* \brief C++ API: Locale ID object.
|
|
|
|
|
*/
|
2000-09-20 18:09:07 +00:00
|
|
|
|
|
2001-11-09 03:31:02 +00:00
|
|
|
|
/**
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* A <code>Locale</code> object 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.
|
|
|
|
|
*
|
2002-11-07 02:38:51 +00:00
|
|
|
|
* The Locale class is not suitable for subclassing.
|
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* <P>
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* You can create a <code>Locale</code> object using the constructor in
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* this class:
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* <pre>
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* . Locale( const char* language,
|
|
|
|
|
* . const char* country,
|
2000-04-15 21:19:44 +00:00
|
|
|
|
* . const char* variant);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* </pre>
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* The first argument to the constructors is a valid <STRONG>ISO
|
|
|
|
|
* Language Code.</STRONG> These codes are the lower-case two-letter
|
|
|
|
|
* codes as defined by ISO-639.
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* You can find a full list of these codes at:
|
|
|
|
|
* <BR><a href ="http://www.loc.gov/standards/iso639-2/">
|
|
|
|
|
* http://www.loc.gov/standards/iso639-2/</a>
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
|
|
|
|
* <P>
|
|
|
|
|
* The second argument to the constructors is a valid <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:
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* <BR><a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html">
|
|
|
|
|
* http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html</a>
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
|
|
|
|
* <P>
|
|
|
|
|
* The third constructor requires a third argument--the <STRONG>Variant.</STRONG>
|
|
|
|
|
* The Variant codes are vendor and browser-specific.
|
2004-12-23 00:41:06 +00:00
|
|
|
|
* For example, use REVISED for a langauge's revised script orthography, and POSIX for POSIX.
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* 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
|
2004-12-23 00:41:06 +00:00
|
|
|
|
* "ES", "ES", "Traditional_POSIX".
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
|
|
|
|
* <P>
|
|
|
|
|
* Because a <code>Locale</code> object is just an identifier for a region,
|
|
|
|
|
* no validity check is performed when you construct a <code>Locale</code>.
|
|
|
|
|
* If you want to see whether particular resources are available for the
|
|
|
|
|
* <code>Locale</code> you construct, you must query those resources. For
|
|
|
|
|
* example, ask the <code>NumberFormat</code> for the locales it supports
|
|
|
|
|
* using its <code>getAvailableLocales</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
|
2003-02-03 22:34:59 +00:00
|
|
|
|
* <code>ResourceBundle</code>.
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
|
|
|
|
* <P>
|
|
|
|
|
* The <code>Locale</code> class provides a number of convenient constants
|
|
|
|
|
* that you can use to create <code>Locale</code> objects for commonly used
|
|
|
|
|
* locales. For example, the following refers to a <code>Locale</code> object
|
|
|
|
|
* for the United States:
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* <pre>
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* Locale::getUS()
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* </pre>
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
|
|
|
|
* <P>
|
|
|
|
|
* Once you've created a <code>Locale</code> you can query it for information about
|
|
|
|
|
* itself. Use <code>getCountry</code> to get the ISO Country Code and
|
|
|
|
|
* <code>getLanguage</code> to get the ISO Language Code. You can
|
|
|
|
|
* use <code>getDisplayCountry</code> to get the
|
|
|
|
|
* name of the country suitable for displaying to the user. Similarly,
|
|
|
|
|
* you can use <code>getDisplayLanguage</code> to get the name of
|
|
|
|
|
* the language suitable for displaying to the user. Interestingly,
|
|
|
|
|
* the <code>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>
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* ICU provides a number of classes that perform locale-sensitive
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* operations. For example, the <code>NumberFormat</code> class formats
|
|
|
|
|
* numbers, currency, or percentages in a locale-sensitive manner. Classes
|
|
|
|
|
* such as <code>NumberFormat</code> have a number of convenience methods
|
|
|
|
|
* for creating a default object of that type. For example, the
|
|
|
|
|
* <code>NumberFormat</code> class provides these three convenience methods
|
|
|
|
|
* for creating a default <code>NumberFormat</code> object:
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* <pre>
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* UErrorCode success = U_ZERO_ERROR;
|
|
|
|
|
* Locale myLocale;
|
|
|
|
|
* NumberFormat *nf;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
*
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* nf = NumberFormat::createInstance( success ); delete nf;
|
|
|
|
|
* nf = NumberFormat::createCurrencyInstance( success ); delete nf;
|
|
|
|
|
* nf = NumberFormat::createPercentInstance( success ); delete nf;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* </pre>
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* Each of these methods has two variants; one with an explicit locale
|
|
|
|
|
* and one without; the latter using the default locale.
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* <pre>
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* nf = NumberFormat::createInstance( myLocale, success ); delete nf;
|
|
|
|
|
* nf = NumberFormat::createCurrencyInstance( myLocale, success ); delete nf;
|
|
|
|
|
* nf = NumberFormat::createPercentInstance( myLocale, success ); delete nf;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* </pre>
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* A <code>Locale</code> is the mechanism for identifying the kind of object
|
|
|
|
|
* (<code>NumberFormat</code>) that you would like to get. The locale is
|
|
|
|
|
* <STRONG>just</STRONG> a mechanism for identifying objects,
|
|
|
|
|
* <STRONG>not</STRONG> a container for the objects themselves.
|
|
|
|
|
*
|
|
|
|
|
* <P>
|
|
|
|
|
* Each class 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:
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly<blockquote>\endhtmlonly
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* <pre>
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* static Locale* getAvailableLocales(int32_t& numLocales)
|
|
|
|
|
* static UnicodeString& getDisplayName(const Locale& objectLocale,
|
|
|
|
|
* const Locale& displayLocale,
|
|
|
|
|
* UnicodeString& displayName)
|
|
|
|
|
* static UnicodeString& getDisplayName(const Locale& objectLocale,
|
|
|
|
|
* UnicodeString& displayName)
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* </pre>
|
2004-06-15 22:32:41 +00:00
|
|
|
|
* \htmlonly</blockquote>\endhtmlonly
|
2001-11-13 22:47:47 +00:00
|
|
|
|
*
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2003-02-03 22:34:59 +00:00
|
|
|
|
* @see ResourceBundle
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-10-08 23:26:58 +00:00
|
|
|
|
U_NAMESPACE_BEGIN
|
2002-06-27 01:19:20 +00:00
|
|
|
|
class U_COMMON_API Locale : public UObject {
|
1999-12-28 23:39:02 +00:00
|
|
|
|
public:
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getEnglish(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getFrench(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getGerman(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getItalian(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getJapanese(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getKorean(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getChinese(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getSimplifiedChinese(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this language. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getTraditionalChinese(void);
|
2001-08-10 22:36:26 +00:00
|
|
|
|
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getFrance(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getGermany(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getItaly(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getJapan(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getKorea(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getChina(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getPRC(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getTaiwan(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getUK(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getUS(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getCanada(void);
|
2002-12-05 00:30:16 +00:00
|
|
|
|
/** Useful constant for this country/region. @stable ICU 2.0 */
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale &U_EXPORT2 getCanadaFrench(void);
|
2001-08-10 22:36:26 +00:00
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
2003-05-14 00:30:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* Construct a default locale object, a Locale for the default locale ID.
|
|
|
|
|
*
|
|
|
|
|
* @see getDefault
|
|
|
|
|
* @see uloc_getDefault
|
|
|
|
|
* @stable ICU 2.0
|
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
Locale();
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct a locale from language, country, variant.
|
2003-05-14 00:30:50 +00:00
|
|
|
|
* If an error occurs, then the constructed object will be "bogus"
|
|
|
|
|
* (isBogus() will return TRUE).
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
2003-05-14 00:30:50 +00:00
|
|
|
|
* @param language Lowercase two-letter or three-letter ISO-639 code.
|
|
|
|
|
* This parameter can instead be an ICU style C locale (e.g. "en_US"),
|
|
|
|
|
* but the other parameters must not be used.
|
|
|
|
|
* This parameter can be NULL; if so,
|
2002-08-01 23:21:35 +00:00
|
|
|
|
* the locale is initialized to match the current default locale.
|
2003-05-14 00:30:50 +00:00
|
|
|
|
* (This is the same as using the default constructor.)
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* Please note: The Java Locale class does NOT accept the form
|
2002-10-15 22:00:55 +00:00
|
|
|
|
* 'new Locale("en_US")' but only 'new Locale("en","US")'
|
2004-08-24 17:21:14 +00:00
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* @param country Uppercase two-letter ISO-3166 code. (optional)
|
|
|
|
|
* @param variant Uppercase vendor and browser specific code. See class
|
|
|
|
|
* description. (optional)
|
2003-10-15 05:30:32 +00:00
|
|
|
|
* @param keywordsAndValues A string consisting of keyword/values pairs, such as
|
|
|
|
|
* "collation=phonebook;currency=euro"
|
2003-05-14 00:30:50 +00:00
|
|
|
|
*
|
|
|
|
|
* @see getDefault
|
|
|
|
|
* @see uloc_getDefault
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
Locale( const char * language,
|
2004-08-24 17:21:14 +00:00
|
|
|
|
const char * country = 0,
|
2003-10-15 05:30:32 +00:00
|
|
|
|
const char * variant = 0,
|
|
|
|
|
const char * keywordsAndValues = 0);
|
2001-03-06 01:27:32 +00:00
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Initializes a Locale object from another Locale object.
|
|
|
|
|
*
|
|
|
|
|
* @param other The Locale object being copied in.
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
Locale(const Locale& other);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2004-08-26 20:39:32 +00:00
|
|
|
|
virtual ~Locale() ;
|
2001-03-06 01:27:32 +00:00
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Replaces the entire contents of *this with the specified value.
|
|
|
|
|
*
|
|
|
|
|
* @param other The Locale object being copied in.
|
|
|
|
|
* @return *this
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
Locale& operator=(const Locale& other);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if two locale keys are the same.
|
|
|
|
|
*
|
|
|
|
|
* @param other The locale key object to be compared with this.
|
|
|
|
|
* @return True if the two locale keys are the same, false otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UBool operator==(const Locale& other) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if two locale keys are not the same.
|
|
|
|
|
*
|
|
|
|
|
* @param other The locale key object to be compared with this.
|
|
|
|
|
* @return True if the two locale keys are not the same, false
|
|
|
|
|
* otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UBool operator!=(const Locale& other) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
2003-11-05 02:26:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* Clone this object.
|
|
|
|
|
* Clones can be used concurrently in multiple threads.
|
|
|
|
|
* If an error occurs, then NULL is returned.
|
|
|
|
|
* The caller must delete the clone.
|
|
|
|
|
*
|
|
|
|
|
* @return a clone of this object
|
|
|
|
|
*
|
|
|
|
|
* @see getDynamicClassID
|
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
|
|
|
|
Locale *clone() const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Common methods of getting the current default Locale. Used for the
|
|
|
|
|
* presentation: menus, dialogs, etc. Generally set once when your applet or
|
|
|
|
|
* application is initialized, then never reset. (If you do reset the
|
|
|
|
|
* default locale, you probably want to reload your GUI, so that the change
|
|
|
|
|
* is reflected in your interface.)
|
|
|
|
|
*
|
|
|
|
|
* More advanced programs will allow users to use different locales for
|
|
|
|
|
* different fields, e.g. in a spreadsheet.
|
|
|
|
|
*
|
|
|
|
|
* Note that the initial setting will match the host system.
|
2003-05-14 00:30:50 +00:00
|
|
|
|
* @return a reference to the Locale object for the default locale ID
|
2000-03-22 18:31:40 +00:00
|
|
|
|
* @system
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale& U_EXPORT2 getDefault(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2003-05-14 00:30:50 +00:00
|
|
|
|
* Sets the default. Normally set once at the beginning of a process,
|
|
|
|
|
* then never reset.
|
|
|
|
|
* setDefault() only changes ICU's default locale ID, <strong>not</strong>
|
|
|
|
|
* the default locale ID of the runtime environment.
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*
|
2003-07-24 01:15:10 +00:00
|
|
|
|
* @param newLocale Locale to set to. If NULL, set to the value obtained
|
|
|
|
|
* from the runtime environement.
|
2002-07-03 12:05:56 +00:00
|
|
|
|
* @param success The error code.
|
2000-03-22 18:31:40 +00:00
|
|
|
|
* @system
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static void U_EXPORT2 setDefault(const Locale& newLocale,
|
|
|
|
|
UErrorCode& success);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
2001-02-17 13:33:57 +00:00
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* Creates a locale which has had minimal canonicalization
|
|
|
|
|
* as per uloc_getName().
|
2001-08-18 00:06:11 +00:00
|
|
|
|
* @param name The name to create from. If name is null,
|
|
|
|
|
* the default Locale is used.
|
2001-02-17 13:33:57 +00:00
|
|
|
|
* @return new locale object
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2001-02-17 13:33:57 +00:00
|
|
|
|
* @see uloc_getName
|
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static Locale U_EXPORT2 createFromName(const char *name);
|
2001-02-17 13:33:57 +00:00
|
|
|
|
|
2004-05-15 05:10:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Creates a locale from the given string after canonicalizing
|
|
|
|
|
* the string by calling uloc_canonicalize().
|
|
|
|
|
* @param name the locale ID to create from. Must not be NULL.
|
|
|
|
|
* @return a new locale object corresponding to the given name
|
|
|
|
|
* @draft ICU 3.0
|
|
|
|
|
* @see uloc_canonicalize
|
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static Locale U_EXPORT2 createCanonical(const char* name);
|
|
|
|
|
|
2000-04-15 21:19:44 +00:00
|
|
|
|
/**
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* Returns the locale's ISO-639 language code.
|
2000-04-15 21:19:44 +00:00
|
|
|
|
* @return An alias to the code
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-07-02 20:26:33 +00:00
|
|
|
|
inline const char * getLanguage( ) const;
|
2001-03-06 01:27:32 +00:00
|
|
|
|
|
2003-10-03 23:57:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the locale's ISO-15924 abbreviation script code.
|
|
|
|
|
* @return An alias to the code
|
|
|
|
|
* @see uscript_getShortName
|
|
|
|
|
* @see uscript_getCode
|
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
|
|
|
|
inline const char * getScript( ) const;
|
|
|
|
|
|
2000-04-15 21:19:44 +00:00
|
|
|
|
/**
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* Returns the locale's ISO-3166 country code.
|
2000-04-15 21:19:44 +00:00
|
|
|
|
* @return An alias to the code
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-07-02 20:26:33 +00:00
|
|
|
|
inline const char * getCountry( ) const;
|
2001-03-06 01:27:32 +00:00
|
|
|
|
|
2000-04-15 21:19:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the locale's variant code.
|
|
|
|
|
* @return An alias to the code
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-07-02 20:26:33 +00:00
|
|
|
|
inline const char * getVariant( ) const;
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the programmatic name of the entire locale, with the language,
|
|
|
|
|
* country and variant separated by underbars. If a field is missing, up
|
|
|
|
|
* to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN",
|
|
|
|
|
* "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO"
|
|
|
|
|
* @return A pointer to "name".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-07-02 20:26:33 +00:00
|
|
|
|
inline const char * getName() const;
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
2003-11-12 23:50:21 +00:00
|
|
|
|
/**
|
2004-01-23 21:41:05 +00:00
|
|
|
|
* Returns the programmatic name of the entire locale as getName would return,
|
|
|
|
|
* but without keywords.
|
2003-11-12 23:50:21 +00:00
|
|
|
|
* @return A pointer to "name".
|
2004-01-23 21:41:05 +00:00
|
|
|
|
* @see getName
|
2003-11-12 23:50:21 +00:00
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
|
|
|
|
const char * getBaseName() const;
|
|
|
|
|
|
|
|
|
|
|
2003-10-15 05:30:32 +00:00
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* Gets the list of keywords for the specified locale.
|
2003-10-15 05:30:32 +00:00
|
|
|
|
*
|
|
|
|
|
* @return pointer to StringEnumeration class. Client must dispose of it by calling delete.
|
2003-11-24 19:59:15 +00:00
|
|
|
|
* @param status Returns any error information while performing this operation.
|
2003-10-15 05:30:32 +00:00
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
2003-11-12 23:50:21 +00:00
|
|
|
|
StringEnumeration * createKeywords(UErrorCode &status) const;
|
2003-10-15 05:30:32 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* Get the value for a keyword.
|
|
|
|
|
*
|
2003-10-15 05:30:32 +00:00
|
|
|
|
* @param keywordName name of the keyword for which we want the value. Case insensitive.
|
2003-11-24 19:59:15 +00:00
|
|
|
|
* @param status Returns any error information while performing this operation.
|
2004-05-27 18:06:17 +00:00
|
|
|
|
* @param buffer The buffer to receive the keyword value.
|
|
|
|
|
* @param bufferCapacity The capacity of receiving buffer
|
|
|
|
|
* @return the length of keyword value
|
2003-10-15 05:30:32 +00:00
|
|
|
|
*
|
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
|
2003-10-15 05:30:32 +00:00
|
|
|
|
|
2000-04-15 21:19:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* returns the locale's three-letter language code, as specified
|
|
|
|
|
* in ISO draft standard ISO-639-2..
|
|
|
|
|
* @return An alias to the code, or NULL
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
const char * getISO3Language() const;
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills in "name" with the locale's three-letter ISO-3166 country code.
|
|
|
|
|
* @return An alias to the code, or NULL
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
const char * getISO3Country() const;
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns the Windows LCID value corresponding to this locale.
|
|
|
|
|
* This value is stored in the resource data for the locale as a one-to-four-digit
|
|
|
|
|
* hexadecimal number. If the resource is missing, in the wrong format, or
|
|
|
|
|
* there is no Windows LCID value that corresponds to this locale, returns 0.
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
uint32_t getLCID(void) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispLang" with the name of this locale's language in a format suitable for
|
|
|
|
|
* user display in the default locale. For example, if the locale's language code is
|
|
|
|
|
* "fr" and the default locale's language code is "en", this function would set
|
|
|
|
|
* dispLang to "French".
|
|
|
|
|
* @param dispLang Receives the language's display name.
|
|
|
|
|
* @return A reference to "dispLang".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispLang" with the name of this locale's language in a format suitable for
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* user display in the locale specified by "displayLocale". For example, if the locale's
|
|
|
|
|
* language code is "en" and displayLocale's language code is "fr", this function would set
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* dispLang to "Anglais".
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* @param displayLocale Specifies the locale to be used to display the name. In other words,
|
2001-11-09 03:31:02 +00:00
|
|
|
|
* if the locale's language code is "en", passing Locale::getFrench() for
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* displayLocale would result in "Anglais", while passing Locale::getGerman()
|
|
|
|
|
* for displayLocale would result in "Englisch".
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* @param dispLang Receives the language's display name.
|
|
|
|
|
* @return A reference to "dispLang".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2003-10-03 23:57:04 +00:00
|
|
|
|
UnicodeString& getDisplayLanguage( const Locale& displayLocale,
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& dispLang) const;
|
|
|
|
|
|
2003-10-03 23:57:04 +00:00
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispScript" with the name of this locale's script in a format suitable
|
|
|
|
|
* for user display in the default locale. For example, if the locale's script code
|
|
|
|
|
* is "LATN" and the default locale's language code is "en", this function would set
|
|
|
|
|
* dispScript to "Latin".
|
2003-10-08 22:14:00 +00:00
|
|
|
|
* @param dispScript Receives the scripts's display name.
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* @return A reference to "dispScript".
|
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
|
|
|
|
UnicodeString& getDisplayScript( UnicodeString& dispScript) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispScript" with the name of this locale's country in a format suitable
|
|
|
|
|
* for user display in the locale specified by "displayLocale". For example, if the locale's
|
|
|
|
|
* script code is "LATN" and displayLocale's language code is "en", this function would set
|
|
|
|
|
* dispScript to "Latin".
|
|
|
|
|
* @param displayLocale Specifies the locale to be used to display the name. In other
|
|
|
|
|
* words, if the locale's script code is "LATN", passing
|
|
|
|
|
* Locale::getFrench() for displayLocale would result in "", while
|
|
|
|
|
* passing Locale::getGerman() for displayLocale would result in
|
|
|
|
|
* "".
|
2003-10-08 22:14:00 +00:00
|
|
|
|
* @param dispScript Receives the scripts's display name.
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* @return A reference to "dispScript".
|
|
|
|
|
* @draft ICU 2.8
|
|
|
|
|
*/
|
|
|
|
|
UnicodeString& getDisplayScript( const Locale& displayLocale,
|
|
|
|
|
UnicodeString& dispScript) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispCountry" with the name of this locale's country in a format suitable
|
|
|
|
|
* for user display in the default locale. For example, if the locale's country code
|
|
|
|
|
* is "FR" and the default locale's language code is "en", this function would set
|
|
|
|
|
* dispCountry to "France".
|
|
|
|
|
* @param dispCountry Receives the country's display name.
|
|
|
|
|
* @return A reference to "dispCountry".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispCountry" with the name of this locale's country in a format suitable
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* for user display in the locale specified by "displayLocale". For example, if the locale's
|
|
|
|
|
* country code is "US" and displayLocale's language code is "fr", this function would set
|
2004-12-23 00:41:06 +00:00
|
|
|
|
* dispCountry to "États-Unis".
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* @param displayLocale Specifies the locale to be used to display the name. In other
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* words, if the locale's country code is "US", passing
|
2004-12-23 00:41:06 +00:00
|
|
|
|
* Locale::getFrench() for displayLocale would result in "États-Unis", while
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* passing Locale::getGerman() for displayLocale would result in
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* "Vereinigte Staaten".
|
|
|
|
|
* @param dispCountry Receives the country's display name.
|
|
|
|
|
* @return A reference to "dispCountry".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2003-10-03 23:57:04 +00:00
|
|
|
|
UnicodeString& getDisplayCountry( const Locale& displayLocale,
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& dispCountry) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispVar" with the name of this locale's variant code in a format suitable
|
|
|
|
|
* for user display in the default locale.
|
|
|
|
|
* @param dispVar Receives the variant's name.
|
|
|
|
|
* @return A reference to "dispVar".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Fills in "dispVar" with the name of this locale's variant code in a format
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* suitable for user display in the locale specified by "displayLocale".
|
|
|
|
|
* @param displayLocale Specifies the locale to be used to display the name.
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* @param dispVar Receives the variant's display name.
|
|
|
|
|
* @return A reference to "dispVar".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2003-10-03 23:57:04 +00:00
|
|
|
|
UnicodeString& getDisplayVariant( const Locale& displayLocale,
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& dispVar) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* Fills in "name" with the name of this locale in a format suitable for user display
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* in the default locale. This function uses getDisplayLanguage(), getDisplayCountry(),
|
|
|
|
|
* and getDisplayVariant() to do its work, and outputs the display name in the format
|
|
|
|
|
* "language (country[,variant])". For example, if the default locale is en_US, then
|
|
|
|
|
* fr_FR's display name would be "French (France)", and es_MX_Traditional's display name
|
|
|
|
|
* would be "Spanish (Mexico,Traditional)".
|
|
|
|
|
* @param name Receives the locale's display name.
|
|
|
|
|
* @return A reference to "name".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& getDisplayName( UnicodeString& name) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
|
* Fills in "name" with the name of this locale in a format suitable for user display
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* in the locale specfied by "displayLocale". This function uses getDisplayLanguage(),
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* name in the format "language (country[,variant])". For example, if displayLocale is
|
2004-11-12 01:11:27 +00:00
|
|
|
|
* fr_FR, then en_US's display name would be "Anglais (États-Unis)", and no_NO_NY's
|
|
|
|
|
* display name would be "norvégien (Norv<72>ge,NY)".
|
2003-10-03 23:57:04 +00:00
|
|
|
|
* @param displayLocale Specifies the locale to be used to display the name.
|
1999-12-28 23:39:02 +00:00
|
|
|
|
* @param name Receives the locale's display name.
|
|
|
|
|
* @return A reference to "name".
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2003-10-03 23:57:04 +00:00
|
|
|
|
UnicodeString& getDisplayName( const Locale& displayLocale,
|
2001-03-06 01:27:32 +00:00
|
|
|
|
UnicodeString& name) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
2000-04-15 21:19:44 +00:00
|
|
|
|
* Generates a hash code for the locale.
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2001-03-06 01:27:32 +00:00
|
|
|
|
int32_t hashCode(void) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* Sets the locale to bogus
|
|
|
|
|
* A bogus locale represents a non-existing locale associated
|
|
|
|
|
* with services that can be instantiated from non-locale data
|
|
|
|
|
* in addition to locale (for example, collation can be
|
|
|
|
|
* instantiated from a locale and from a rule set).
|
2003-06-04 00:04:35 +00:00
|
|
|
|
* @stable ICU 2.1
|
2002-02-28 21:32:28 +00:00
|
|
|
|
*/
|
2002-03-13 05:14:56 +00:00
|
|
|
|
void setToBogus();
|
2002-02-28 21:32:28 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the bogus state. Locale object can be bogus if it doesn't exist
|
|
|
|
|
* @return FALSE if it is a real locale, TRUE if it is a bogus locale
|
2003-06-04 00:04:35 +00:00
|
|
|
|
* @stable ICU 2.1
|
2002-02-28 21:32:28 +00:00
|
|
|
|
*/
|
|
|
|
|
UBool isBogus(void) const;
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns a list of all installed locales.
|
|
|
|
|
* @param count Receives the number of locales in the list.
|
|
|
|
|
* @return A pointer to an array of Locale objects. This array is the list
|
|
|
|
|
* of all locales with installed resource files. The called does NOT
|
|
|
|
|
* get ownership of this list, and must NOT delete it.
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
2000-04-15 21:19:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* Gets a list of all available 2-letter country codes defined in ISO 639. This is a
|
|
|
|
|
* pointer to an array of pointers to arrays of char. All of these pointers are
|
|
|
|
|
* owned by ICU-- do not delete them, and do not write through them. The array is
|
|
|
|
|
* terminated with a null pointer.
|
|
|
|
|
* @return a list of all available country codes
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const char* const* U_EXPORT2 getISOCountries();
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets a list of all available language codes defined in ISO 639. This is a pointer
|
|
|
|
|
* to an array of pointers to arrays of char. All of these pointers are owned
|
|
|
|
|
* by ICU-- do not delete them, and do not write through them. The array is
|
|
|
|
|
* terminated with a null pointer.
|
|
|
|
|
* @return a list of all available language codes
|
2002-12-04 23:39:56 +00:00
|
|
|
|
* @stable ICU 2.0
|
2000-04-15 21:19:44 +00:00
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static const char* const* U_EXPORT2 getISOLanguages();
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
|
/**
|
2003-08-27 01:01:42 +00:00
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
2002-06-29 00:04:16 +00:00
|
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
|
static UClassID U_EXPORT2 getStaticClassID();
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2003-08-27 01:01:42 +00:00
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
2002-06-29 00:04:16 +00:00
|
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
|
*/
|
2003-08-27 01:01:42 +00:00
|
|
|
|
virtual UClassID getDynamicClassID() const;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
2000-09-20 18:09:07 +00:00
|
|
|
|
protected: /* only protected for testing purposes. DO NOT USE. */
|
2002-12-17 23:20:06 +00:00
|
|
|
|
/**
|
|
|
|
|
* Set this from a single POSIX style locale string.
|
|
|
|
|
* @internal
|
|
|
|
|
*/
|
2001-05-17 15:30:07 +00:00
|
|
|
|
void setFromPOSIXID(const char *posixID);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/**
|
2000-04-15 21:19:44 +00:00
|
|
|
|
* Initialize the locale object with a new name.
|
|
|
|
|
* Was deprecated - used in implementation - moved internal
|
|
|
|
|
*
|
|
|
|
|
* @param cLocaleID The new locale name.
|
1999-12-28 23:39:02 +00:00
|
|
|
|
*/
|
2004-05-15 05:10:07 +00:00
|
|
|
|
Locale& init(const char* cLocaleID, UBool canonicalize);
|
2001-03-06 01:27:32 +00:00
|
|
|
|
|
2003-05-09 21:25:07 +00:00
|
|
|
|
/*
|
|
|
|
|
* Internal constructor to allow construction of a locale object with
|
|
|
|
|
* NO side effects. (Default constructor tries to get
|
|
|
|
|
* the default locale.)
|
|
|
|
|
*/
|
|
|
|
|
enum ELocaleType {
|
|
|
|
|
eBOGUS
|
|
|
|
|
};
|
|
|
|
|
Locale(ELocaleType);
|
|
|
|
|
|
2001-08-10 22:36:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* Initialize the locale cache for commonly used locales
|
|
|
|
|
*/
|
2003-05-08 23:56:37 +00:00
|
|
|
|
static Locale *getLocaleCache(void);
|
2001-03-06 01:27:32 +00:00
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
char language[ULOC_LANG_CAPACITY];
|
2003-10-03 23:57:04 +00:00
|
|
|
|
char script[ULOC_SCRIPT_CAPACITY];
|
1999-12-28 23:39:02 +00:00
|
|
|
|
char country[ULOC_COUNTRY_CAPACITY];
|
2001-08-10 22:36:26 +00:00
|
|
|
|
int32_t variantBegin;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
char* fullName;
|
|
|
|
|
char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
|
2003-11-12 23:50:21 +00:00
|
|
|
|
// name without keywords
|
|
|
|
|
char* baseName;
|
|
|
|
|
char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
|
2002-02-28 21:32:28 +00:00
|
|
|
|
|
|
|
|
|
UBool fIsBogus;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
2001-08-10 22:36:26 +00:00
|
|
|
|
static const Locale &getLocale(int locid);
|
2000-04-15 21:19:44 +00:00
|
|
|
|
|
2003-10-08 22:14:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* A friend to allow the default locale to be set by either the C or C++ API.
|
|
|
|
|
* @internal
|
|
|
|
|
*/
|
2001-09-07 03:34:02 +00:00
|
|
|
|
friend void locale_set_default_internal(const char *);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
|
Locale::operator!=(const Locale& other) const
|
|
|
|
|
{
|
|
|
|
|
return !operator==(other);
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-02 20:26:33 +00:00
|
|
|
|
inline const char *
|
|
|
|
|
Locale::getCountry() const
|
|
|
|
|
{
|
|
|
|
|
return country;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline const char *
|
|
|
|
|
Locale::getLanguage() const
|
|
|
|
|
{
|
|
|
|
|
return language;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-03 23:57:04 +00:00
|
|
|
|
inline const char *
|
|
|
|
|
Locale::getScript() const
|
|
|
|
|
{
|
|
|
|
|
return script;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-02 20:26:33 +00:00
|
|
|
|
inline const char *
|
|
|
|
|
Locale::getVariant() const
|
|
|
|
|
{
|
2001-08-10 22:36:26 +00:00
|
|
|
|
return &fullName[variantBegin];
|
2001-07-02 20:26:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
|
inline const char *
|
2001-07-02 20:26:33 +00:00
|
|
|
|
Locale::getName() const
|
|
|
|
|
{
|
|
|
|
|
return fullName;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
|
inline UBool
|
2002-02-28 21:32:28 +00:00
|
|
|
|
Locale::isBogus(void) const {
|
2003-02-14 01:33:13 +00:00
|
|
|
|
return fIsBogus;
|
2001-08-10 22:36:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
|
U_NAMESPACE_END
|
2001-08-10 22:36:26 +00:00
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
#endif
|
2003-10-08 22:14:00 +00:00
|
|
|
|
|