Locale Class Reference

A Locale object represents a specific geographical, political, or cultural region. More...

#include <locid.h>

Inheritance diagram for Locale:
UObject UMemory

Public Member Functions

 Locale ()
 Construct a default locale object, a Locale for the default locale ID.
 Locale (const char *language, const char *country=0, const char *variant=0, const char *keywordsAndValues=0)
 Construct a locale from language, country, variant.
 Locale (const Locale &other)
 Initializes a Locale object from another Locale object.
virtual ~Locale ()
 Destructor.
Localeoperator= (const Locale &other)
 Replaces the entire contents of *this with the specified value.
UBool operator== (const Locale &other) const
 Checks if two locale keys are the same.
UBool operator!= (const Locale &other) const
 Checks if two locale keys are not the same.
Localeclone () const
 Clone this object.
const char * getLanguage () const
 Returns the locale's ISO-639 language code.
const char * getScript () const
 Returns the locale's ISO-15924 abbreviation script code.
const char * getCountry () const
 Returns the locale's ISO-3166 country code.
const char * getVariant () const
 Returns the locale's variant code.
const char * getName () const
 Returns the programmatic name of the entire locale, with the language, country and variant separated by underbars.
const char * getBaseName () const
 Returns the programmatic name of the entire locale as getName would return, but without keywords.
StringEnumerationcreateKeywords (UErrorCode &status) const
 Gets the list of keywords for the specified locale.
int32_t getKeywordValue (const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const
 Get the value for a keyword.
void setKeywordValue (const char *keywordName, const char *keywordValue, UErrorCode &status)
 Set the value for a keyword.
const char * getISO3Language () const
 returns the locale's three-letter language code, as specified in ISO draft standard ISO-639-2.
const char * getISO3Country () const
 Fills in "name" with the locale's three-letter ISO-3166 country code.
uint32_t getLCID (void) const
 Returns the Windows LCID value corresponding to this locale.
UnicodeStringgetDisplayLanguage (UnicodeString &dispLang) const
 Fills in "dispLang" with the name of this locale's language in a format suitable for user display in the default locale.
UnicodeStringgetDisplayLanguage (const Locale &displayLocale, UnicodeString &dispLang) const
 Fills in "dispLang" with the name of this locale's language in a format suitable for user display in the locale specified by "displayLocale".
UnicodeStringgetDisplayScript (UnicodeString &dispScript) const
 Fills in "dispScript" with the name of this locale's script in a format suitable for user display in the default locale.
UnicodeStringgetDisplayScript (const Locale &displayLocale, 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".
UnicodeStringgetDisplayCountry (UnicodeString &dispCountry) const
 Fills in "dispCountry" with the name of this locale's country in a format suitable for user display in the default locale.
UnicodeStringgetDisplayCountry (const Locale &displayLocale, UnicodeString &dispCountry) const
 Fills in "dispCountry" with the name of this locale's country in a format suitable for user display in the locale specified by "displayLocale".
UnicodeStringgetDisplayVariant (UnicodeString &dispVar) const
 Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the default locale.
UnicodeStringgetDisplayVariant (const Locale &displayLocale, UnicodeString &dispVar) const
 Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the locale specified by "displayLocale".
UnicodeStringgetDisplayName (UnicodeString &name) const
 Fills in "name" with the name of this locale in a format suitable for user display in the default locale.
UnicodeStringgetDisplayName (const Locale &displayLocale, UnicodeString &name) const
 Fills in "name" with the name of this locale in a format suitable for user display in the locale specfied by "displayLocale".
int32_t hashCode (void) const
 Generates a hash code for the locale.
void setToBogus ()
 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).
UBool isBogus (void) const
 Gets the bogus state.
virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class.

Static Public Member Functions

static const LocalegetRoot (void)
 Useful constant for the Root locale.
static const LocalegetEnglish (void)
 Useful constant for this language.
static const LocalegetFrench (void)
 Useful constant for this language.
static const LocalegetGerman (void)
 Useful constant for this language.
static const LocalegetItalian (void)
 Useful constant for this language.
static const LocalegetJapanese (void)
 Useful constant for this language.
static const LocalegetKorean (void)
 Useful constant for this language.
static const LocalegetChinese (void)
 Useful constant for this language.
static const LocalegetSimplifiedChinese (void)
 Useful constant for this language.
static const LocalegetTraditionalChinese (void)
 Useful constant for this language.
static const LocalegetFrance (void)
 Useful constant for this country/region.
static const LocalegetGermany (void)
 Useful constant for this country/region.
static const LocalegetItaly (void)
 Useful constant for this country/region.
static const LocalegetJapan (void)
 Useful constant for this country/region.
static const LocalegetKorea (void)
 Useful constant for this country/region.
static const LocalegetChina (void)
 Useful constant for this country/region.
static const LocalegetPRC (void)
 Useful constant for this country/region.
static const LocalegetTaiwan (void)
 Useful constant for this country/region.
static const LocalegetUK (void)
 Useful constant for this country/region.
static const LocalegetUS (void)
 Useful constant for this country/region.
static const LocalegetCanada (void)
 Useful constant for this country/region.
static const LocalegetCanadaFrench (void)
 Useful constant for this country/region.
static const LocalegetDefault (void)
 Common methods of getting the current default Locale.
static void setDefault (const Locale &newLocale, UErrorCode &success)
 Sets the default.
static Locale createFromName (const char *name)
 Creates a locale which has had minimal canonicalization as per uloc_getName().
static Locale createCanonical (const char *name)
 Creates a locale from the given string after canonicalizing the string by calling uloc_canonicalize().
static const LocalegetAvailableLocales (int32_t &count)
 Returns a list of all installed locales.
static const char *const * getISOCountries ()
 Gets a list of all available 2-letter country codes defined in ISO 3166.
static const char *const * getISOLanguages ()
 Gets a list of all available language codes defined in ISO 639.
static UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class.

Protected Member Functions

void setFromPOSIXID (const char *posixID)
 Set this from a single POSIX style locale string.

Friends

void locale_set_default_internal (const char *)
 A friend to allow the default locale to be set by either the C or C++ API.

Detailed Description

A Locale object represents a specific geographical, political, or cultural region.

An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale 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.

The Locale class is not suitable for subclassing.

You can create a Locale object using the constructor in this class:

       Locale( const   char*  language,
               const   char*  country,
               const   char*  variant);
 
The first argument to the constructors is a valid ISO Language Code. These codes are the lower-case two-letter codes as defined by ISO-639. You can find a full list of these codes at:
http://www.loc.gov/standards/iso639-2/

The second argument to the constructors is a valid ISO Country Code. 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:
http://www.iso.org/iso/en/prods-services/iso3166ma/index.html

The third constructor requires a third argument--the Variant. The Variant codes are vendor and browser-specific. For example, use REVISED for a langauge's revised script orthography, 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_POSIX".

Because a Locale object is just an identifier for a region, no validity check is performed when you construct a Locale. If you want to see whether particular resources are available for the Locale you construct, you must query those resources. For example, ask the NumberFormat for the locales it supports using its getAvailableLocales method.
Note: 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 ResourceBundle.

The Locale class provides a number of convenient constants that you can use to create Locale objects for commonly used locales. For example, the following refers to a Locale object for the United States:

       Locale::getUS()
 

Once you've created a Locale you can query it for information about itself. Use getCountry to get the ISO Country Code and getLanguage to get the ISO Language Code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user. Similarly, you can use getDisplayLanguage to get the name of the language suitable for displaying to the user. Interestingly, the getDisplayXXX 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.

ICU provides a number of classes that perform locale-sensitive operations. For example, the NumberFormat class formats numbers, currency, or percentages in a locale-sensitive manner. Classes such as NumberFormat have a number of convenience methods for creating a default object of that type. For example, the NumberFormat class provides these three convenience methods for creating a default NumberFormat object:

     UErrorCode success = U_ZERO_ERROR;
     Locale myLocale;
     NumberFormat *nf;
     nf = NumberFormat::createInstance( success );          delete nf;
     nf = NumberFormat::createCurrencyInstance( success );  delete nf;
     nf = NumberFormat::createPercentInstance( success );   delete nf;
 
Each of these methods has two variants; one with an explicit locale and one without; the latter using the default locale.
     nf = NumberFormat::createInstance( myLocale, success );          delete nf;
     nf = NumberFormat::createCurrencyInstance( myLocale, success );  delete nf;
     nf = NumberFormat::createPercentInstance( myLocale, success );   delete nf;
 
A Locale is the mechanism for identifying the kind of object (NumberFormat) that you would like to get. The locale is just a mechanism for identifying objects, not a container for the objects themselves.

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:

       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)
 
Stable:
ICU 2.0
See also:
ResourceBundle

Definition at line 181 of file locid.h.


Constructor & Destructor Documentation

Locale::Locale (  ) 

Construct a default locale object, a Locale for the default locale ID.

See also:
getDefault
uloc_getDefault
Stable:
ICU 2.0
Locale::Locale ( const char *  language,
const char *  country = 0,
const char *  variant = 0,
const char *  keywordsAndValues = 0 
)

Construct a locale from language, country, variant.

If an error occurs, then the constructed object will be "bogus" (isBogus() will return TRUE).

Parameters:
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, the locale is initialized to match the current default locale. (This is the same as using the default constructor.) Please note: The Java Locale class does NOT accept the form 'new Locale("en_US")' but only 'new Locale("en","US")'
country Uppercase two-letter ISO-3166 code. (optional)
variant Uppercase vendor and browser specific code. See class description. (optional)
keywordsAndValues A string consisting of keyword/values pairs, such as "collation=phonebook;currency=euro"
See also:
getDefault
uloc_getDefault
Stable:
ICU 2.0
Locale::Locale ( const Locale other  ) 

Initializes a Locale object from another Locale object.

Parameters:
other The Locale object being copied in.
Stable:
ICU 2.0
virtual Locale::~Locale (  )  [virtual]

Destructor.

Stable:
ICU 2.0

Member Function Documentation

Locale* Locale::clone (  )  const

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.

Returns:
a clone of this object
See also:
getDynamicClassID
Stable:
ICU 2.8
static Locale Locale::createCanonical ( const char *  name  )  [static]

Creates a locale from the given string after canonicalizing the string by calling uloc_canonicalize().

Parameters:
name the locale ID to create from. Must not be NULL.
Returns:
a new locale object corresponding to the given name
Stable:
ICU 3.0
See also:
uloc_canonicalize
static Locale Locale::createFromName ( const char *  name  )  [static]

Creates a locale which has had minimal canonicalization as per uloc_getName().

Parameters:
name The name to create from. If name is null, the default Locale is used.
Returns:
new locale object
Stable:
ICU 2.0
See also:
uloc_getName
StringEnumeration* Locale::createKeywords ( UErrorCode status  )  const

Gets the list of keywords for the specified locale.

Parameters:
status the status code
Returns:
pointer to StringEnumeration class, or NULL if there are no keywords. Client must dispose of it by calling delete.
Stable:
ICU 2.8
static const Locale* Locale::getAvailableLocales ( int32_t &  count  )  [static]

Returns a list of all installed locales.

Parameters:
count Receives the number of locales in the list.
Returns:
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.
Stable:
ICU 2.0
const char* Locale::getBaseName (  )  const

Returns the programmatic name of the entire locale as getName would return, but without keywords.

Returns:
A pointer to "name".
See also:
getName
Stable:
ICU 2.8

Referenced by getVariant().

static const Locale& Locale::getCanada ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getCanadaFrench ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getChina ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getChinese ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
const char * Locale::getCountry (  )  const [inline]

Returns the locale's ISO-3166 country code.

Returns:
An alias to the code
Stable:
ICU 2.0

Definition at line 744 of file locid.h.

static const Locale& Locale::getDefault ( void   )  [static]

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.

Returns:
a reference to the Locale object for the default locale ID
System:
Do not use unless you know what you are doing.
Stable:
ICU 2.0

Referenced by Calendar::createInstance().

UnicodeString& Locale::getDisplayCountry ( const Locale displayLocale,
UnicodeString dispCountry 
) const

Fills in "dispCountry" 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 country code is "US" and displayLocale's language code is "fr", this function would set dispCountry to "&Eacute;tats-Unis".

Parameters:
displayLocale Specifies the locale to be used to display the name. In other words, if the locale's country code is "US", passing Locale::getFrench() for displayLocale would result in "&Eacute;tats-Unis", while passing Locale::getGerman() for displayLocale would result in "Vereinigte Staaten".
dispCountry Receives the country's display name.
Returns:
A reference to "dispCountry".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayCountry ( UnicodeString dispCountry  )  const

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".

Parameters:
dispCountry Receives the country's display name.
Returns:
A reference to "dispCountry".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayLanguage ( const Locale displayLocale,
UnicodeString dispLang 
) const

Fills in "dispLang" with the name of this locale's language in a format suitable for 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 dispLang to "Anglais".

Parameters:
displayLocale Specifies the locale to be used to display the name. In other words, if the locale's language code is "en", passing Locale::getFrench() for displayLocale would result in "Anglais", while passing Locale::getGerman() for displayLocale would result in "Englisch".
dispLang Receives the language's display name.
Returns:
A reference to "dispLang".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayLanguage ( UnicodeString dispLang  )  const

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".

Parameters:
dispLang Receives the language's display name.
Returns:
A reference to "dispLang".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayName ( const Locale displayLocale,
UnicodeString name 
) const

Fills in "name" with the name of this locale in a format suitable for user display in the locale specfied by "displayLocale".

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 displayLocale is fr_FR, then en_US's display name would be "Anglais (&Eacute;tats-Unis)", and no_NO_NY's display name would be "norv&eacute;gien (Norv&egrave;ge,NY)".

Parameters:
displayLocale Specifies the locale to be used to display the name.
name Receives the locale's display name.
Returns:
A reference to "name".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayName ( UnicodeString name  )  const

Fills in "name" with the name of this locale in a format suitable for user display 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)".

Parameters:
name Receives the locale's display name.
Returns:
A reference to "name".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayScript ( const Locale displayLocale,
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".

Parameters:
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 "".
dispScript Receives the scripts's display name.
Returns:
A reference to "dispScript".
Stable:
ICU 2.8
UnicodeString& Locale::getDisplayScript ( UnicodeString dispScript  )  const

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".

Parameters:
dispScript Receives the scripts's display name.
Returns:
A reference to "dispScript".
Stable:
ICU 2.8
UnicodeString& Locale::getDisplayVariant ( const Locale displayLocale,
UnicodeString dispVar 
) const

Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the locale specified by "displayLocale".

Parameters:
displayLocale Specifies the locale to be used to display the name.
dispVar Receives the variant's display name.
Returns:
A reference to "dispVar".
Stable:
ICU 2.0
UnicodeString& Locale::getDisplayVariant ( UnicodeString dispVar  )  const

Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display in the default locale.

Parameters:
dispVar Receives the variant's name.
Returns:
A reference to "dispVar".
Stable:
ICU 2.0
virtual UClassID Locale::getDynamicClassID (  )  const [virtual]

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 2.2

Implements UObject.

static const Locale& Locale::getEnglish ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
static const Locale& Locale::getFrance ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getFrench ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
static const Locale& Locale::getGerman ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
static const Locale& Locale::getGermany ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
const char* Locale::getISO3Country (  )  const

Fills in "name" with the locale's three-letter ISO-3166 country code.

Returns:
An alias to the code, or NULL
Stable:
ICU 2.0
const char* Locale::getISO3Language (  )  const

returns the locale's three-letter language code, as specified in ISO draft standard ISO-639-2.

Returns:
An alias to the code, or NULL
Stable:
ICU 2.0
static const char* const* Locale::getISOCountries (  )  [static]

Gets a list of all available 2-letter country codes defined in ISO 3166.

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.

Returns:
a list of all available country codes
Stable:
ICU 2.0
static const char* const* Locale::getISOLanguages (  )  [static]

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.

Returns:
a list of all available language codes
Stable:
ICU 2.0
static const Locale& Locale::getItalian ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
static const Locale& Locale::getItaly ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getJapan ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getJapanese ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
int32_t Locale::getKeywordValue ( const char *  keywordName,
char *  buffer,
int32_t  bufferCapacity,
UErrorCode status 
) const

Get the value for a keyword.

Parameters:
keywordName name of the keyword for which we want the value. Case insensitive.
buffer The buffer to receive the keyword value.
bufferCapacity The capacity of receiving buffer
status Returns any error information while performing this operation.
Returns:
the length of the keyword value
Stable:
ICU 2.8
static const Locale& Locale::getKorea ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getKorean ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
const char * Locale::getLanguage (  )  const [inline]

Returns the locale's ISO-639 language code.

Returns:
An alias to the code
Stable:
ICU 2.0

Definition at line 750 of file locid.h.

uint32_t Locale::getLCID ( void   )  const

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.

Stable:
ICU 2.0
const char * Locale::getName (  )  const [inline]

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"

Returns:
A pointer to "name".
Stable:
ICU 2.0

Definition at line 769 of file locid.h.

static const Locale& Locale::getPRC ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getRoot ( void   )  [static]

Useful constant for the Root locale.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.4
const char * Locale::getScript (  )  const [inline]

Returns the locale's ISO-15924 abbreviation script code.

Returns:
An alias to the code
See also:
uscript_getShortName
uscript_getCode
Stable:
ICU 2.8

Definition at line 756 of file locid.h.

static const Locale& Locale::getSimplifiedChinese ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
static UClassID Locale::getStaticClassID (  )  [static]

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 2.2
static const Locale& Locale::getTaiwan ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getTraditionalChinese ( void   )  [static]

Useful constant for this language.

Stable:
ICU 2.0
static const Locale& Locale::getUK ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
static const Locale& Locale::getUS ( void   )  [static]

Useful constant for this country/region.

Stable:
ICU 2.0
const char * Locale::getVariant (  )  const [inline]

Returns the locale's variant code.

Returns:
An alias to the code
Stable:
ICU 2.0

Definition at line 762 of file locid.h.

References getBaseName().

int32_t Locale::hashCode ( void   )  const

Generates a hash code for the locale.

Stable:
ICU 2.0
UBool Locale::isBogus ( void   )  const [inline]

Gets the bogus state.

Locale object can be bogus if it doesn't exist

Returns:
FALSE if it is a real locale, TRUE if it is a bogus locale
Stable:
ICU 2.1

Definition at line 775 of file locid.h.

UBool Locale::operator!= ( const Locale other  )  const [inline]

Checks if two locale keys are not the same.

Parameters:
other The locale key object to be compared with this.
Returns:
True if the two locale keys are not the same, false otherwise.
Stable:
ICU 2.0

Definition at line 738 of file locid.h.

References operator==().

Locale& Locale::operator= ( const Locale other  ) 

Replaces the entire contents of *this with the specified value.

Parameters:
other The Locale object being copied in.
Returns:
*this
Stable:
ICU 2.0
UBool Locale::operator== ( const Locale other  )  const

Checks if two locale keys are the same.

Parameters:
other The locale key object to be compared with this.
Returns:
True if the two locale keys are the same, false otherwise.
Stable:
ICU 2.0

Referenced by operator!=().

static void Locale::setDefault ( const Locale newLocale,
UErrorCode success 
) [static]

Sets the default.

Normally set once at the beginning of a process, then never reset. setDefault() only changes ICU's default locale ID, not the default locale ID of the runtime environment.

Parameters:
newLocale Locale to set to. If NULL, set to the value obtained from the runtime environement.
success The error code.
System:
Do not use unless you know what you are doing.
Stable:
ICU 2.0
void Locale::setFromPOSIXID ( const char *  posixID  )  [protected]

Set this from a single POSIX style locale string.

Internal:
Do not use. This API is for internal use only.
void Locale::setKeywordValue ( const char *  keywordName,
const char *  keywordValue,
UErrorCode status 
)

Set the value for a keyword.

Parameters:
keywordName name of the keyword to be set. Case insensitive.
keywordValue value of the keyword to be set. If 0-length or NULL, will result in the keyword being removed. No error is given if that keyword does not exist.
status Returns any error information while performing this operation.
Internal:
Do not use. This API is for internal use only.
void Locale::setToBogus (  ) 

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).

Stable:
ICU 2.1

Friends And Related Function Documentation

void locale_set_default_internal ( const char *   )  [friend]

A friend to allow the default locale to be set by either the C or C++ API.

Internal:
Do not use. This API is for internal use only.

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sat Jan 23 15:17:43 2010 for ICU 4.3.4 by  doxygen 1.6.1