os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/locid.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
******************************************************************************
sl@0
     3
*
sl@0
     4
*   Copyright (C) 1996-2005, International Business Machines
sl@0
     5
*   Corporation and others.  All Rights Reserved.
sl@0
     6
*
sl@0
     7
******************************************************************************
sl@0
     8
*
sl@0
     9
* File locid.h
sl@0
    10
*
sl@0
    11
* Created by: Helena Shih
sl@0
    12
*
sl@0
    13
* Modification History:
sl@0
    14
*
sl@0
    15
*   Date        Name        Description
sl@0
    16
*   02/11/97    aliu        Changed gLocPath to fgLocPath and added methods to
sl@0
    17
*                           get and set it.
sl@0
    18
*   04/02/97    aliu        Made operator!= inline; fixed return value of getName().
sl@0
    19
*   04/15/97    aliu        Cleanup for AIX/Win32.
sl@0
    20
*   04/24/97    aliu        Numerous changes per code review.
sl@0
    21
*   08/18/98    stephen     Added tokenizeString(),changed getDisplayName()
sl@0
    22
*   09/08/98    stephen     Moved definition of kEmptyString for Mac Port
sl@0
    23
*   11/09/99    weiv        Added const char * getName() const;
sl@0
    24
*   04/12/00    srl         removing unicodestring api's and cached hash code
sl@0
    25
*   08/10/01    grhoten     Change the static Locales to accessor functions
sl@0
    26
******************************************************************************
sl@0
    27
*/
sl@0
    28
sl@0
    29
#ifndef LOCID_H
sl@0
    30
#define LOCID_H
sl@0
    31
sl@0
    32
#include "unicode/utypes.h"
sl@0
    33
#include "unicode/uobject.h"
sl@0
    34
#include "unicode/unistr.h"
sl@0
    35
#include "unicode/putil.h"
sl@0
    36
#include "unicode/uloc.h"
sl@0
    37
#include "unicode/strenum.h"
sl@0
    38
sl@0
    39
/**
sl@0
    40
 * \file
sl@0
    41
 * \brief C++ API: Locale ID object.
sl@0
    42
 */
sl@0
    43
sl@0
    44
/**
sl@0
    45
 * A <code>Locale</code> object represents a specific geographical, political,
sl@0
    46
 * or cultural region. An operation that requires a <code>Locale</code> to perform
sl@0
    47
 * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>
sl@0
    48
 * to tailor information for the user. For example, displaying a number
sl@0
    49
 * is a locale-sensitive operation--the number should be formatted
sl@0
    50
 * according to the customs/conventions of the user's native country,
sl@0
    51
 * region, or culture.
sl@0
    52
 *
sl@0
    53
 * The Locale class is not suitable for subclassing.
sl@0
    54
 *
sl@0
    55
 * <P>
sl@0
    56
 * You can create a <code>Locale</code> object using the constructor in
sl@0
    57
 * this class:
sl@0
    58
 * \htmlonly<blockquote>\endhtmlonly
sl@0
    59
 * <pre>
sl@0
    60
 * .      Locale( const   char*  language,
sl@0
    61
 * .              const   char*  country,
sl@0
    62
 * .              const   char*  variant);
sl@0
    63
 * </pre>
sl@0
    64
 * \htmlonly</blockquote>\endhtmlonly
sl@0
    65
 * The first argument to the constructors is a valid <STRONG>ISO
sl@0
    66
 * Language Code.</STRONG> These codes are the lower-case two-letter
sl@0
    67
 * codes as defined by ISO-639.
sl@0
    68
 * You can find a full list of these codes at:
sl@0
    69
 * <BR><a href ="http://www.loc.gov/standards/iso639-2/">
sl@0
    70
 * http://www.loc.gov/standards/iso639-2/</a>
sl@0
    71
 *
sl@0
    72
 * <P>
sl@0
    73
 * The second argument to the constructors is a valid <STRONG>ISO Country
sl@0
    74
 * Code.</STRONG> These codes are the upper-case two-letter codes
sl@0
    75
 * as defined by ISO-3166.
sl@0
    76
 * You can find a full list of these codes at a number of sites, such as:
sl@0
    77
 * <BR><a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html">
sl@0
    78
 * http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html</a>
sl@0
    79
 *
sl@0
    80
 * <P>
sl@0
    81
 * The third constructor requires a third argument--the <STRONG>Variant.</STRONG>
sl@0
    82
 * The Variant codes are vendor and browser-specific.
sl@0
    83
 * For example, use REVISED for a langauge's revised script orthography, and POSIX for POSIX.
sl@0
    84
 * Where there are two variants, separate them with an underscore, and
sl@0
    85
 * put the most important one first. For
sl@0
    86
 * example, a Traditional Spanish collation might be referenced, with
sl@0
    87
 * "ES", "ES", "Traditional_POSIX".
sl@0
    88
 *
sl@0
    89
 * <P>
sl@0
    90
 * Because a <code>Locale</code> object is just an identifier for a region,
sl@0
    91
 * no validity check is performed when you construct a <code>Locale</code>.
sl@0
    92
 * If you want to see whether particular resources are available for the
sl@0
    93
 * <code>Locale</code> you construct, you must query those resources. For
sl@0
    94
 * example, ask the <code>NumberFormat</code> for the locales it supports
sl@0
    95
 * using its <code>getAvailableLocales</code> method.
sl@0
    96
 * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular
sl@0
    97
 * locale, you get back the best available match, not necessarily
sl@0
    98
 * precisely what you asked for. For more information, look at
sl@0
    99
 * <code>ResourceBundle</code>.
sl@0
   100
 *
sl@0
   101
 * <P>
sl@0
   102
 * The <code>Locale</code> class provides a number of convenient constants
sl@0
   103
 * that you can use to create <code>Locale</code> objects for commonly used
sl@0
   104
 * locales. For example, the following refers to a <code>Locale</code> object
sl@0
   105
 * for the United States:
sl@0
   106
 * \htmlonly<blockquote>\endhtmlonly
sl@0
   107
 * <pre>
sl@0
   108
 *       Locale::getUS()
sl@0
   109
 * </pre>
sl@0
   110
 * \htmlonly</blockquote>\endhtmlonly
sl@0
   111
 *
sl@0
   112
 * <P>
sl@0
   113
 * Once you've created a <code>Locale</code> you can query it for information about
sl@0
   114
 * itself. Use <code>getCountry</code> to get the ISO Country Code and
sl@0
   115
 * <code>getLanguage</code> to get the ISO Language Code. You can
sl@0
   116
 * use <code>getDisplayCountry</code> to get the
sl@0
   117
 * name of the country suitable for displaying to the user. Similarly,
sl@0
   118
 * you can use <code>getDisplayLanguage</code> to get the name of
sl@0
   119
 * the language suitable for displaying to the user. Interestingly,
sl@0
   120
 * the <code>getDisplayXXX</code> methods are themselves locale-sensitive
sl@0
   121
 * and have two versions: one that uses the default locale and one
sl@0
   122
 * that takes a locale as an argument and displays the name or country in
sl@0
   123
 * a language appropriate to that locale.
sl@0
   124
 *
sl@0
   125
 * <P>
sl@0
   126
 * ICU provides a number of classes that perform locale-sensitive
sl@0
   127
 * operations. For example, the <code>NumberFormat</code> class formats
sl@0
   128
 * numbers, currency, or percentages in a locale-sensitive manner. Classes
sl@0
   129
 * such as <code>NumberFormat</code> have a number of convenience methods
sl@0
   130
 * for creating a default object of that type. For example, the
sl@0
   131
 * <code>NumberFormat</code> class provides these three convenience methods
sl@0
   132
 * for creating a default <code>NumberFormat</code> object:
sl@0
   133
 * \htmlonly<blockquote>\endhtmlonly
sl@0
   134
 * <pre>
sl@0
   135
 *     UErrorCode success = U_ZERO_ERROR;
sl@0
   136
 *     Locale myLocale;
sl@0
   137
 *     NumberFormat *nf;
sl@0
   138
 *
sl@0
   139
 *     nf = NumberFormat::createInstance( success );          delete nf;
sl@0
   140
 *     nf = NumberFormat::createCurrencyInstance( success );  delete nf;
sl@0
   141
 *     nf = NumberFormat::createPercentInstance( success );   delete nf;
sl@0
   142
 * </pre>
sl@0
   143
 * \htmlonly</blockquote>\endhtmlonly
sl@0
   144
 * Each of these methods has two variants; one with an explicit locale
sl@0
   145
 * and one without; the latter using the default locale.
sl@0
   146
 * \htmlonly<blockquote>\endhtmlonly
sl@0
   147
 * <pre>
sl@0
   148
 *     nf = NumberFormat::createInstance( myLocale, success );          delete nf;
sl@0
   149
 *     nf = NumberFormat::createCurrencyInstance( myLocale, success );  delete nf;
sl@0
   150
 *     nf = NumberFormat::createPercentInstance( myLocale, success );   delete nf;
sl@0
   151
 * </pre>
sl@0
   152
 * \htmlonly</blockquote>\endhtmlonly
sl@0
   153
 * A <code>Locale</code> is the mechanism for identifying the kind of object
sl@0
   154
 * (<code>NumberFormat</code>) that you would like to get. The locale is
sl@0
   155
 * <STRONG>just</STRONG> a mechanism for identifying objects,
sl@0
   156
 * <STRONG>not</STRONG> a container for the objects themselves.
sl@0
   157
 *
sl@0
   158
 * <P>
sl@0
   159
 * Each class that performs locale-sensitive operations allows you
sl@0
   160
 * to get all the available objects of that type. You can sift
sl@0
   161
 * through these objects by language, country, or variant,
sl@0
   162
 * and use the display names to present a menu to the user.
sl@0
   163
 * For example, you can create a menu of all the collation objects
sl@0
   164
 * suitable for a given language. Such classes implement these
sl@0
   165
 * three class methods:
sl@0
   166
 * \htmlonly<blockquote>\endhtmlonly
sl@0
   167
 * <pre>
sl@0
   168
 *       static Locale* getAvailableLocales(int32_t& numLocales)
sl@0
   169
 *       static UnicodeString& getDisplayName(const Locale&  objectLocale,
sl@0
   170
 *                                            const Locale&  displayLocale,
sl@0
   171
 *                                            UnicodeString& displayName)
sl@0
   172
 *       static UnicodeString& getDisplayName(const Locale&  objectLocale,
sl@0
   173
 *                                            UnicodeString& displayName)
sl@0
   174
 * </pre>
sl@0
   175
 * \htmlonly</blockquote>\endhtmlonly
sl@0
   176
 *
sl@0
   177
 * @stable ICU 2.0
sl@0
   178
 * @see ResourceBundle
sl@0
   179
 */
sl@0
   180
U_NAMESPACE_BEGIN
sl@0
   181
class U_COMMON_API Locale : public UObject {
sl@0
   182
public:
sl@0
   183
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   184
    static const Locale &U_EXPORT2 getEnglish(void);
sl@0
   185
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   186
    static const Locale &U_EXPORT2 getFrench(void);
sl@0
   187
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   188
    static const Locale &U_EXPORT2 getGerman(void);
sl@0
   189
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   190
    static const Locale &U_EXPORT2 getItalian(void);
sl@0
   191
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   192
    static const Locale &U_EXPORT2 getJapanese(void);
sl@0
   193
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   194
    static const Locale &U_EXPORT2 getKorean(void);
sl@0
   195
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   196
    static const Locale &U_EXPORT2 getChinese(void);
sl@0
   197
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   198
    static const Locale &U_EXPORT2 getSimplifiedChinese(void);
sl@0
   199
    /** Useful constant for this language. @stable ICU 2.0 */
sl@0
   200
    static const Locale &U_EXPORT2 getTraditionalChinese(void);
sl@0
   201
sl@0
   202
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   203
    static const Locale &U_EXPORT2 getFrance(void);
sl@0
   204
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   205
    static const Locale &U_EXPORT2 getGermany(void);
sl@0
   206
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   207
    static const Locale &U_EXPORT2 getItaly(void);
sl@0
   208
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   209
    static const Locale &U_EXPORT2 getJapan(void);
sl@0
   210
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   211
    static const Locale &U_EXPORT2 getKorea(void);
sl@0
   212
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   213
    static const Locale &U_EXPORT2 getChina(void);
sl@0
   214
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   215
    static const Locale &U_EXPORT2 getPRC(void);
sl@0
   216
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   217
    static const Locale &U_EXPORT2 getTaiwan(void);
sl@0
   218
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   219
    static const Locale &U_EXPORT2 getUK(void);
sl@0
   220
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   221
    static const Locale &U_EXPORT2 getUS(void);
sl@0
   222
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   223
    static const Locale &U_EXPORT2 getCanada(void);
sl@0
   224
    /** Useful constant for this country/region. @stable ICU 2.0 */
sl@0
   225
    static const Locale &U_EXPORT2 getCanadaFrench(void);
sl@0
   226
sl@0
   227
sl@0
   228
    /**
sl@0
   229
     * Construct a default locale object, a Locale for the default locale ID.
sl@0
   230
     *
sl@0
   231
     * @see getDefault
sl@0
   232
     * @see uloc_getDefault
sl@0
   233
     * @stable ICU 2.0
sl@0
   234
     */
sl@0
   235
    Locale();
sl@0
   236
sl@0
   237
    /**
sl@0
   238
     * Construct a locale from language, country, variant.
sl@0
   239
     * If an error occurs, then the constructed object will be "bogus"
sl@0
   240
     * (isBogus() will return TRUE).
sl@0
   241
     *
sl@0
   242
     * @param language Lowercase two-letter or three-letter ISO-639 code.
sl@0
   243
     *  This parameter can instead be an ICU style C locale (e.g. "en_US"),
sl@0
   244
     *  but the other parameters must not be used.
sl@0
   245
     *  This parameter can be NULL; if so,
sl@0
   246
     *  the locale is initialized to match the current default locale.
sl@0
   247
     *  (This is the same as using the default constructor.)
sl@0
   248
     *  Please note: The Java Locale class does NOT accept the form
sl@0
   249
     *  'new Locale("en_US")' but only 'new Locale("en","US")'
sl@0
   250
     *
sl@0
   251
     * @param country  Uppercase two-letter ISO-3166 code. (optional)
sl@0
   252
     * @param variant  Uppercase vendor and browser specific code. See class
sl@0
   253
     *                 description. (optional)
sl@0
   254
     * @param keywordsAndValues A string consisting of keyword/values pairs, such as
sl@0
   255
     *                 "collation=phonebook;currency=euro"
sl@0
   256
     *
sl@0
   257
     * @see getDefault
sl@0
   258
     * @see uloc_getDefault
sl@0
   259
     * @stable ICU 2.0
sl@0
   260
     */
sl@0
   261
    Locale( const   char * language,
sl@0
   262
            const   char * country  = 0,
sl@0
   263
            const   char * variant  = 0,
sl@0
   264
            const   char * keywordsAndValues = 0);
sl@0
   265
sl@0
   266
    /**
sl@0
   267
     * Initializes a Locale object from another Locale object.
sl@0
   268
     *
sl@0
   269
     * @param other The Locale object being copied in.
sl@0
   270
     * @stable ICU 2.0
sl@0
   271
     */
sl@0
   272
    Locale(const    Locale& other);
sl@0
   273
sl@0
   274
sl@0
   275
    /**
sl@0
   276
     * Destructor
sl@0
   277
     * @stable ICU 2.0
sl@0
   278
     */
sl@0
   279
    virtual ~Locale() ;
sl@0
   280
sl@0
   281
    /**
sl@0
   282
     * Replaces the entire contents of *this with the specified value.
sl@0
   283
     *
sl@0
   284
     * @param other The Locale object being copied in.
sl@0
   285
     * @return      *this
sl@0
   286
     * @stable ICU 2.0
sl@0
   287
     */
sl@0
   288
    Locale& operator=(const Locale& other);
sl@0
   289
sl@0
   290
    /**
sl@0
   291
     * Checks if two locale keys are the same.
sl@0
   292
     *
sl@0
   293
     * @param other The locale key object to be compared with this.
sl@0
   294
     * @return      True if the two locale keys are the same, false otherwise.
sl@0
   295
     * @stable ICU 2.0
sl@0
   296
     */
sl@0
   297
    UBool   operator==(const    Locale&     other) const;
sl@0
   298
sl@0
   299
    /**
sl@0
   300
     * Checks if two locale keys are not the same.
sl@0
   301
     *
sl@0
   302
     * @param other The locale key object to be compared with this.
sl@0
   303
     * @return      True if the two locale keys are not the same, false
sl@0
   304
     *              otherwise.
sl@0
   305
     * @stable ICU 2.0
sl@0
   306
     */
sl@0
   307
    UBool   operator!=(const    Locale&     other) const;
sl@0
   308
sl@0
   309
    /**
sl@0
   310
     * Clone this object.
sl@0
   311
     * Clones can be used concurrently in multiple threads.
sl@0
   312
     * If an error occurs, then NULL is returned.
sl@0
   313
     * The caller must delete the clone.
sl@0
   314
     *
sl@0
   315
     * @return a clone of this object
sl@0
   316
     *
sl@0
   317
     * @see getDynamicClassID
sl@0
   318
     * @stable ICU 2.8
sl@0
   319
     */
sl@0
   320
    Locale *clone() const;
sl@0
   321
sl@0
   322
    /**
sl@0
   323
     * Common methods of getting the current default Locale. Used for the
sl@0
   324
     * presentation: menus, dialogs, etc. Generally set once when your applet or
sl@0
   325
     * application is initialized, then never reset. (If you do reset the
sl@0
   326
     * default locale, you probably want to reload your GUI, so that the change
sl@0
   327
     * is reflected in your interface.)
sl@0
   328
     *
sl@0
   329
     * More advanced programs will allow users to use different locales for
sl@0
   330
     * different fields, e.g. in a spreadsheet.
sl@0
   331
     *
sl@0
   332
     * Note that the initial setting will match the host system.
sl@0
   333
     * @return a reference to the Locale object for the default locale ID
sl@0
   334
     * @system
sl@0
   335
     * @stable ICU 2.0
sl@0
   336
     */
sl@0
   337
    static const Locale& U_EXPORT2 getDefault(void);
sl@0
   338
sl@0
   339
    /**
sl@0
   340
     * Sets the default. Normally set once at the beginning of a process,
sl@0
   341
     * then never reset.
sl@0
   342
     * setDefault() only changes ICU's default locale ID, <strong>not</strong>
sl@0
   343
     * the default locale ID of the runtime environment.
sl@0
   344
     *
sl@0
   345
     * @param newLocale Locale to set to.  If NULL, set to the value obtained
sl@0
   346
     *                  from the runtime environement.
sl@0
   347
     * @param success The error code.
sl@0
   348
     * @system
sl@0
   349
     * @stable ICU 2.0
sl@0
   350
     */
sl@0
   351
    static void U_EXPORT2 setDefault(const Locale& newLocale,
sl@0
   352
                                     UErrorCode&   success);
sl@0
   353
sl@0
   354
    /**
sl@0
   355
     * Creates a locale which has had minimal canonicalization
sl@0
   356
     * as per uloc_getName().
sl@0
   357
     * @param name The name to create from.  If name is null,
sl@0
   358
     *  the default Locale is used.
sl@0
   359
     * @return new locale object
sl@0
   360
     * @stable ICU 2.0
sl@0
   361
     * @see uloc_getName
sl@0
   362
     */
sl@0
   363
    static Locale U_EXPORT2 createFromName(const char *name);
sl@0
   364
sl@0
   365
    /**
sl@0
   366
     * Creates a locale from the given string after canonicalizing
sl@0
   367
     * the string by calling uloc_canonicalize().
sl@0
   368
     * @param name the locale ID to create from.  Must not be NULL.
sl@0
   369
     * @return a new locale object corresponding to the given name
sl@0
   370
     * @draft ICU 3.0
sl@0
   371
     * @see uloc_canonicalize
sl@0
   372
     */
sl@0
   373
    static Locale U_EXPORT2 createCanonical(const char* name);
sl@0
   374
sl@0
   375
    /**
sl@0
   376
     * Returns the locale's ISO-639 language code.
sl@0
   377
     * @return      An alias to the code
sl@0
   378
     * @stable ICU 2.0
sl@0
   379
     */
sl@0
   380
    inline const char *  getLanguage( ) const;
sl@0
   381
sl@0
   382
    /**
sl@0
   383
     * Returns the locale's ISO-15924 abbreviation script code.
sl@0
   384
     * @return      An alias to the code
sl@0
   385
     * @see uscript_getShortName
sl@0
   386
     * @see uscript_getCode
sl@0
   387
     * @stable ICU 2.8
sl@0
   388
     */
sl@0
   389
    inline const char *  getScript( ) const;
sl@0
   390
sl@0
   391
    /**
sl@0
   392
     * Returns the locale's ISO-3166 country code.
sl@0
   393
     * @return      An alias to the code
sl@0
   394
     * @stable ICU 2.0
sl@0
   395
     */
sl@0
   396
    inline const char *  getCountry( ) const;
sl@0
   397
sl@0
   398
    /**
sl@0
   399
     * Returns the locale's variant code.
sl@0
   400
     * @return      An alias to the code
sl@0
   401
     * @stable ICU 2.0
sl@0
   402
     */
sl@0
   403
    inline const char *  getVariant( ) const;
sl@0
   404
sl@0
   405
    /**
sl@0
   406
     * Returns the programmatic name of the entire locale, with the language,
sl@0
   407
     * country and variant separated by underbars. If a field is missing, up
sl@0
   408
     * to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN",
sl@0
   409
     * "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO"
sl@0
   410
     * @return      A pointer to "name".
sl@0
   411
     * @stable ICU 2.0
sl@0
   412
     */
sl@0
   413
    inline const char * getName() const;
sl@0
   414
sl@0
   415
    /**
sl@0
   416
     * Returns the programmatic name of the entire locale as getName would return,
sl@0
   417
     * but without keywords.
sl@0
   418
     * @return      A pointer to "name".
sl@0
   419
     * @see getName
sl@0
   420
     * @stable ICU 2.8
sl@0
   421
     */
sl@0
   422
    const char * getBaseName() const;
sl@0
   423
sl@0
   424
sl@0
   425
    /**
sl@0
   426
     * Gets the list of keywords for the specified locale.
sl@0
   427
     *
sl@0
   428
     * @return pointer to StringEnumeration class. Client must dispose of it by calling delete.
sl@0
   429
     * @param status Returns any error information while performing this operation.
sl@0
   430
     * @stable ICU 2.8
sl@0
   431
     */
sl@0
   432
    StringEnumeration * createKeywords(UErrorCode &status) const;
sl@0
   433
sl@0
   434
    /**
sl@0
   435
     * Get the value for a keyword.
sl@0
   436
     *
sl@0
   437
     * @param keywordName name of the keyword for which we want the value. Case insensitive.
sl@0
   438
     * @param status Returns any error information while performing this operation.
sl@0
   439
     * @param buffer The buffer to receive the keyword value.
sl@0
   440
     * @param bufferCapacity The capacity of receiving buffer
sl@0
   441
     * @return the length of keyword value
sl@0
   442
     *
sl@0
   443
     * @stable ICU 2.8
sl@0
   444
     */
sl@0
   445
    int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
sl@0
   446
sl@0
   447
    /**
sl@0
   448
     * returns the locale's three-letter language code, as specified
sl@0
   449
     * in ISO draft standard ISO-639-2..
sl@0
   450
     * @return      An alias to the code, or NULL
sl@0
   451
     * @stable ICU 2.0
sl@0
   452
     */
sl@0
   453
    const char * getISO3Language() const;
sl@0
   454
sl@0
   455
    /**
sl@0
   456
     * Fills in "name" with the locale's three-letter ISO-3166 country code.
sl@0
   457
     * @return      An alias to the code, or NULL
sl@0
   458
     * @stable ICU 2.0
sl@0
   459
     */
sl@0
   460
    const char * getISO3Country() const;
sl@0
   461
sl@0
   462
    /**
sl@0
   463
     * Returns the Windows LCID value corresponding to this locale.
sl@0
   464
     * This value is stored in the resource data for the locale as a one-to-four-digit
sl@0
   465
     * hexadecimal number.  If the resource is missing, in the wrong format, or
sl@0
   466
     * there is no Windows LCID value that corresponds to this locale, returns 0.
sl@0
   467
     * @stable ICU 2.0
sl@0
   468
     */
sl@0
   469
    uint32_t        getLCID(void) const;
sl@0
   470
sl@0
   471
    /**
sl@0
   472
     * Fills in "dispLang" with the name of this locale's language in a format suitable for
sl@0
   473
     * user display in the default locale.  For example, if the locale's language code is
sl@0
   474
     * "fr" and the default locale's language code is "en", this function would set
sl@0
   475
     * dispLang to "French".
sl@0
   476
     * @param dispLang  Receives the language's display name.
sl@0
   477
     * @return          A reference to "dispLang".
sl@0
   478
     * @stable ICU 2.0
sl@0
   479
     */
sl@0
   480
    UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
sl@0
   481
sl@0
   482
    /**
sl@0
   483
     * Fills in "dispLang" with the name of this locale's language in a format suitable for
sl@0
   484
     * user display in the locale specified by "displayLocale".  For example, if the locale's
sl@0
   485
     * language code is "en" and displayLocale's language code is "fr", this function would set
sl@0
   486
     * dispLang to "Anglais".
sl@0
   487
     * @param displayLocale  Specifies the locale to be used to display the name.  In other words,
sl@0
   488
     *                  if the locale's language code is "en", passing Locale::getFrench() for
sl@0
   489
     *                  displayLocale would result in "Anglais", while passing Locale::getGerman()
sl@0
   490
     *                  for displayLocale would result in "Englisch".
sl@0
   491
     * @param dispLang  Receives the language's display name.
sl@0
   492
     * @return          A reference to "dispLang".
sl@0
   493
     * @stable ICU 2.0
sl@0
   494
     */
sl@0
   495
    UnicodeString&  getDisplayLanguage( const   Locale&         displayLocale,
sl@0
   496
                                                UnicodeString&  dispLang) const;
sl@0
   497
sl@0
   498
    /**
sl@0
   499
     * Fills in "dispScript" with the name of this locale's script in a format suitable
sl@0
   500
     * for user display in the default locale.  For example, if the locale's script code
sl@0
   501
     * is "LATN" and the default locale's language code is "en", this function would set
sl@0
   502
     * dispScript to "Latin".
sl@0
   503
     * @param dispScript    Receives the scripts's display name.
sl@0
   504
     * @return              A reference to "dispScript".
sl@0
   505
     * @stable ICU 2.8
sl@0
   506
     */
sl@0
   507
    UnicodeString&  getDisplayScript(          UnicodeString& dispScript) const;
sl@0
   508
sl@0
   509
    /**
sl@0
   510
     * Fills in "dispScript" with the name of this locale's country in a format suitable
sl@0
   511
     * for user display in the locale specified by "displayLocale".  For example, if the locale's
sl@0
   512
     * script code is "LATN" and displayLocale's language code is "en", this function would set
sl@0
   513
     * dispScript to "Latin".
sl@0
   514
     * @param displayLocale      Specifies the locale to be used to display the name.  In other
sl@0
   515
     *                      words, if the locale's script code is "LATN", passing
sl@0
   516
     *                      Locale::getFrench() for displayLocale would result in "", while
sl@0
   517
     *                      passing Locale::getGerman() for displayLocale would result in
sl@0
   518
     *                      "".
sl@0
   519
     * @param dispScript    Receives the scripts's display name.
sl@0
   520
     * @return              A reference to "dispScript".
sl@0
   521
     * @stable ICU 2.8
sl@0
   522
     */
sl@0
   523
    UnicodeString&  getDisplayScript(  const   Locale&         displayLocale,
sl@0
   524
                                               UnicodeString&  dispScript) const;
sl@0
   525
sl@0
   526
    /**
sl@0
   527
     * Fills in "dispCountry" with the name of this locale's country in a format suitable
sl@0
   528
     * for user display in the default locale.  For example, if the locale's country code
sl@0
   529
     * is "FR" and the default locale's language code is "en", this function would set
sl@0
   530
     * dispCountry to "France".
sl@0
   531
     * @param dispCountry   Receives the country's display name.
sl@0
   532
     * @return              A reference to "dispCountry".
sl@0
   533
     * @stable ICU 2.0
sl@0
   534
     */
sl@0
   535
    UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
sl@0
   536
sl@0
   537
    /**
sl@0
   538
     * Fills in "dispCountry" with the name of this locale's country in a format suitable
sl@0
   539
     * for user display in the locale specified by "displayLocale".  For example, if the locale's
sl@0
   540
     * country code is "US" and displayLocale's language code is "fr", this function would set
sl@0
   541
     * dispCountry to "&Eacute;tats-Unis".
sl@0
   542
     * @param displayLocale      Specifies the locale to be used to display the name.  In other
sl@0
   543
     *                      words, if the locale's country code is "US", passing
sl@0
   544
     *                      Locale::getFrench() for displayLocale would result in "&Eacute;tats-Unis", while
sl@0
   545
     *                      passing Locale::getGerman() for displayLocale would result in
sl@0
   546
     *                      "Vereinigte Staaten".
sl@0
   547
     * @param dispCountry   Receives the country's display name.
sl@0
   548
     * @return              A reference to "dispCountry".
sl@0
   549
     * @stable ICU 2.0
sl@0
   550
     */
sl@0
   551
    UnicodeString&  getDisplayCountry(  const   Locale&         displayLocale,
sl@0
   552
                                                UnicodeString&  dispCountry) const;
sl@0
   553
sl@0
   554
    /**
sl@0
   555
     * Fills in "dispVar" with the name of this locale's variant code in a format suitable
sl@0
   556
     * for user display in the default locale.
sl@0
   557
     * @param dispVar   Receives the variant's name.
sl@0
   558
     * @return          A reference to "dispVar".
sl@0
   559
     * @stable ICU 2.0
sl@0
   560
     */
sl@0
   561
    UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
sl@0
   562
sl@0
   563
    /**
sl@0
   564
     * Fills in "dispVar" with the name of this locale's variant code in a format
sl@0
   565
     * suitable for user display in the locale specified by "displayLocale".
sl@0
   566
     * @param displayLocale  Specifies the locale to be used to display the name.
sl@0
   567
     * @param dispVar   Receives the variant's display name.
sl@0
   568
     * @return          A reference to "dispVar".
sl@0
   569
     * @stable ICU 2.0
sl@0
   570
     */
sl@0
   571
    UnicodeString&  getDisplayVariant(  const   Locale&         displayLocale,
sl@0
   572
                                                UnicodeString&  dispVar) const;
sl@0
   573
sl@0
   574
    /**
sl@0
   575
     * Fills in "name" with the name of this locale in a format suitable for user display
sl@0
   576
     * in the default locale.  This function uses getDisplayLanguage(), getDisplayCountry(),
sl@0
   577
     * and getDisplayVariant() to do its work, and outputs the display name in the format
sl@0
   578
     * "language (country[,variant])".  For example, if the default locale is en_US, then
sl@0
   579
     * fr_FR's display name would be "French (France)", and es_MX_Traditional's display name
sl@0
   580
     * would be "Spanish (Mexico,Traditional)".
sl@0
   581
     * @param name  Receives the locale's display name.
sl@0
   582
     * @return      A reference to "name".
sl@0
   583
     * @stable ICU 2.0
sl@0
   584
     */
sl@0
   585
    UnicodeString&  getDisplayName(         UnicodeString&  name) const;
sl@0
   586
sl@0
   587
    /**
sl@0
   588
     * Fills in "name" with the name of this locale in a format suitable for user display
sl@0
   589
     * in the locale specfied by "displayLocale".  This function uses getDisplayLanguage(),
sl@0
   590
     * getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display
sl@0
   591
     * name in the format "language (country[,variant])".  For example, if displayLocale is
sl@0
   592
     * fr_FR, then en_US's display name would be "Anglais (&Eacute;tats-Unis)", and no_NO_NY's
sl@0
   593
     * display name would be "norv&eacute;gien (Norv&egrave;ge,NY)".
sl@0
   594
     * @param displayLocale  Specifies the locale to be used to display the name.
sl@0
   595
     * @param name      Receives the locale's display name.
sl@0
   596
     * @return          A reference to "name".
sl@0
   597
     * @stable ICU 2.0
sl@0
   598
     */
sl@0
   599
    UnicodeString&  getDisplayName( const   Locale&         displayLocale,
sl@0
   600
                                            UnicodeString&  name) const;
sl@0
   601
sl@0
   602
    /**
sl@0
   603
     * Generates a hash code for the locale.
sl@0
   604
     * @stable ICU 2.0
sl@0
   605
     */
sl@0
   606
    int32_t         hashCode(void) const;
sl@0
   607
sl@0
   608
    /**
sl@0
   609
     * Sets the locale to bogus
sl@0
   610
     * A bogus locale represents a non-existing locale associated
sl@0
   611
     * with services that can be instantiated from non-locale data
sl@0
   612
     * in addition to locale (for example, collation can be
sl@0
   613
     * instantiated from a locale and from a rule set).
sl@0
   614
     * @stable ICU 2.1
sl@0
   615
     */
sl@0
   616
    void setToBogus();
sl@0
   617
sl@0
   618
    /**
sl@0
   619
     * Gets the bogus state. Locale object can be bogus if it doesn't exist
sl@0
   620
     * @return FALSE if it is a real locale, TRUE if it is a bogus locale
sl@0
   621
     * @stable ICU 2.1
sl@0
   622
     */
sl@0
   623
    UBool isBogus(void) const;
sl@0
   624
sl@0
   625
    /**
sl@0
   626
     * Returns a list of all installed locales.
sl@0
   627
     * @param count Receives the number of locales in the list.
sl@0
   628
     * @return      A pointer to an array of Locale objects.  This array is the list
sl@0
   629
     *              of all locales with installed resource files.  The called does NOT
sl@0
   630
     *              get ownership of this list, and must NOT delete it.
sl@0
   631
     * @stable ICU 2.0
sl@0
   632
     */
sl@0
   633
    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
sl@0
   634
sl@0
   635
    /**
sl@0
   636
     * Gets a list of all available 2-letter country codes defined in ISO 639.  This is a
sl@0
   637
     * pointer to an array of pointers to arrays of char.  All of these pointers are
sl@0
   638
     * owned by ICU-- do not delete them, and do not write through them.  The array is
sl@0
   639
     * terminated with a null pointer.
sl@0
   640
     * @return a list of all available country codes
sl@0
   641
     * @stable ICU 2.0
sl@0
   642
     */
sl@0
   643
    static const char* const* U_EXPORT2 getISOCountries();
sl@0
   644
sl@0
   645
    /**
sl@0
   646
     * Gets a list of all available language codes defined in ISO 639.  This is a pointer
sl@0
   647
     * to an array of pointers to arrays of char.  All of these pointers are owned
sl@0
   648
     * by ICU-- do not delete them, and do not write through them.  The array is
sl@0
   649
     * terminated with a null pointer.
sl@0
   650
     * @return a list of all available language codes
sl@0
   651
     * @stable ICU 2.0
sl@0
   652
     */
sl@0
   653
    static const char* const* U_EXPORT2 getISOLanguages();
sl@0
   654
sl@0
   655
    /**
sl@0
   656
     * ICU "poor man's RTTI", returns a UClassID for this class.
sl@0
   657
     *
sl@0
   658
     * @stable ICU 2.2
sl@0
   659
     */
sl@0
   660
    static UClassID U_EXPORT2 getStaticClassID();
sl@0
   661
sl@0
   662
    /**
sl@0
   663
     * ICU "poor man's RTTI", returns a UClassID for the actual class.
sl@0
   664
     *
sl@0
   665
     * @stable ICU 2.2
sl@0
   666
     */
sl@0
   667
    virtual UClassID getDynamicClassID() const;
sl@0
   668
sl@0
   669
protected: /* only protected for testing purposes. DO NOT USE. */
sl@0
   670
    /**
sl@0
   671
     * Set this from a single POSIX style locale string.
sl@0
   672
     * @internal
sl@0
   673
     */
sl@0
   674
    void setFromPOSIXID(const char *posixID);
sl@0
   675
sl@0
   676
private:
sl@0
   677
    /**
sl@0
   678
     * Initialize the locale object with a new name.
sl@0
   679
     * Was deprecated - used in implementation - moved internal
sl@0
   680
     *
sl@0
   681
     * @param cLocaleID The new locale name.
sl@0
   682
     */
sl@0
   683
    Locale& init(const char* cLocaleID, UBool canonicalize);
sl@0
   684
sl@0
   685
    /*
sl@0
   686
     * Internal constructor to allow construction of a locale object with
sl@0
   687
     *   NO side effects.   (Default constructor tries to get
sl@0
   688
     *   the default locale.)
sl@0
   689
     */
sl@0
   690
    enum ELocaleType {
sl@0
   691
        eBOGUS
sl@0
   692
    };
sl@0
   693
    Locale(ELocaleType);
sl@0
   694
sl@0
   695
    /**
sl@0
   696
     * Initialize the locale cache for commonly used locales
sl@0
   697
     */
sl@0
   698
    static Locale *getLocaleCache(void);
sl@0
   699
sl@0
   700
    char language[ULOC_LANG_CAPACITY];
sl@0
   701
    char script[ULOC_SCRIPT_CAPACITY];
sl@0
   702
    char country[ULOC_COUNTRY_CAPACITY];
sl@0
   703
    int32_t variantBegin;
sl@0
   704
    char* fullName;
sl@0
   705
    char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
sl@0
   706
    // name without keywords
sl@0
   707
    char* baseName;
sl@0
   708
    char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
sl@0
   709
sl@0
   710
    UBool fIsBogus;
sl@0
   711
sl@0
   712
    static const Locale &getLocale(int locid);
sl@0
   713
sl@0
   714
    /**
sl@0
   715
     * A friend to allow the default locale to be set by either the C or C++ API.
sl@0
   716
     * @internal
sl@0
   717
     */
sl@0
   718
    friend void locale_set_default_internal(const char *);
sl@0
   719
};
sl@0
   720
sl@0
   721
inline UBool
sl@0
   722
Locale::operator!=(const    Locale&     other) const
sl@0
   723
{
sl@0
   724
    return !operator==(other);
sl@0
   725
}
sl@0
   726
sl@0
   727
inline const char *
sl@0
   728
Locale::getCountry() const
sl@0
   729
{
sl@0
   730
    return country;
sl@0
   731
}
sl@0
   732
sl@0
   733
inline const char *
sl@0
   734
Locale::getLanguage() const
sl@0
   735
{
sl@0
   736
    return language;
sl@0
   737
}
sl@0
   738
sl@0
   739
inline const char *
sl@0
   740
Locale::getScript() const
sl@0
   741
{
sl@0
   742
    return script;
sl@0
   743
}
sl@0
   744
sl@0
   745
inline const char *
sl@0
   746
Locale::getVariant() const
sl@0
   747
{
sl@0
   748
    return &fullName[variantBegin];
sl@0
   749
}
sl@0
   750
sl@0
   751
inline const char *
sl@0
   752
Locale::getName() const
sl@0
   753
{
sl@0
   754
    return fullName;
sl@0
   755
}
sl@0
   756
sl@0
   757
inline UBool
sl@0
   758
Locale::isBogus(void) const {
sl@0
   759
    return fIsBogus;
sl@0
   760
}
sl@0
   761
sl@0
   762
U_NAMESPACE_END
sl@0
   763
sl@0
   764
#endif
sl@0
   765