|
||||
Warning, file /include/unicode/locid.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ****************************************************************************** 0005 * 0006 * Copyright (C) 1996-2015, International Business Machines 0007 * Corporation and others. All Rights Reserved. 0008 * 0009 ****************************************************************************** 0010 * 0011 * File locid.h 0012 * 0013 * Created by: Helena Shih 0014 * 0015 * Modification History: 0016 * 0017 * Date Name Description 0018 * 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to 0019 * get and set it. 0020 * 04/02/97 aliu Made operator!= inline; fixed return value of getName(). 0021 * 04/15/97 aliu Cleanup for AIX/Win32. 0022 * 04/24/97 aliu Numerous changes per code review. 0023 * 08/18/98 stephen Added tokenizeString(),changed getDisplayName() 0024 * 09/08/98 stephen Moved definition of kEmptyString for Mac Port 0025 * 11/09/99 weiv Added const char * getName() const; 0026 * 04/12/00 srl removing unicodestring api's and cached hash code 0027 * 08/10/01 grhoten Change the static Locales to accessor functions 0028 ****************************************************************************** 0029 */ 0030 0031 #ifndef LOCID_H 0032 #define LOCID_H 0033 0034 #include "unicode/utypes.h" 0035 0036 #if U_SHOW_CPLUSPLUS_API 0037 0038 #include "unicode/bytestream.h" 0039 #include "unicode/localpointer.h" 0040 #include "unicode/strenum.h" 0041 #include "unicode/stringpiece.h" 0042 #include "unicode/uobject.h" 0043 #include "unicode/putil.h" 0044 #include "unicode/uloc.h" 0045 0046 /** 0047 * \file 0048 * \brief C++ API: Locale ID object. 0049 */ 0050 0051 U_NAMESPACE_BEGIN 0052 0053 // Forward Declarations 0054 void U_CALLCONV locale_available_init(); /**< @internal */ 0055 0056 class StringEnumeration; 0057 class UnicodeString; 0058 0059 /** 0060 * A <code>Locale</code> object represents a specific geographical, political, 0061 * or cultural region. An operation that requires a <code>Locale</code> to perform 0062 * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code> 0063 * to tailor information for the user. For example, displaying a number 0064 * is a locale-sensitive operation--the number should be formatted 0065 * according to the customs/conventions of the user's native country, 0066 * region, or culture. 0067 * 0068 * The Locale class is not suitable for subclassing. 0069 * 0070 * <P> 0071 * You can create a <code>Locale</code> object using the constructor in 0072 * this class: 0073 * \htmlonly<blockquote>\endhtmlonly 0074 * <pre> 0075 * Locale( const char* language, 0076 * const char* country, 0077 * const char* variant); 0078 * </pre> 0079 * \htmlonly</blockquote>\endhtmlonly 0080 * The first argument to the constructors is a valid <STRONG>ISO 0081 * Language Code.</STRONG> These codes are the lower-case two-letter 0082 * codes as defined by ISO-639. 0083 * You can find a full list of these codes at: 0084 * <BR><a href ="http://www.loc.gov/standards/iso639-2/"> 0085 * http://www.loc.gov/standards/iso639-2/</a> 0086 * 0087 * <P> 0088 * The second argument to the constructors is a valid <STRONG>ISO Country 0089 * Code.</STRONG> These codes are the upper-case two-letter codes 0090 * as defined by ISO-3166. 0091 * You can find a full list of these codes at a number of sites, such as: 0092 * <BR><a href="http://www.iso.org/iso/en/prods-services/iso3166ma/index.html"> 0093 * http://www.iso.org/iso/en/prods-services/iso3166ma/index.html</a> 0094 * 0095 * <P> 0096 * The third constructor requires a third argument--the <STRONG>Variant.</STRONG> 0097 * The Variant codes are vendor and browser-specific. 0098 * For example, use REVISED for a language's revised script orthography, and POSIX for POSIX. 0099 * Where there are two variants, separate them with an underscore, and 0100 * put the most important one first. For 0101 * example, a Traditional Spanish collation might be referenced, with 0102 * "ES", "ES", "Traditional_POSIX". 0103 * 0104 * <P> 0105 * Because a <code>Locale</code> object is just an identifier for a region, 0106 * no validity check is performed when you construct a <code>Locale</code>. 0107 * If you want to see whether particular resources are available for the 0108 * <code>Locale</code> you construct, you must query those resources. For 0109 * example, ask the <code>NumberFormat</code> for the locales it supports 0110 * using its <code>getAvailableLocales</code> method. 0111 * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular 0112 * locale, you get back the best available match, not necessarily 0113 * precisely what you asked for. For more information, look at 0114 * <code>ResourceBundle</code>. 0115 * 0116 * <P> 0117 * The <code>Locale</code> class provides a number of convenient constants 0118 * that you can use to create <code>Locale</code> objects for commonly used 0119 * locales. For example, the following refers to a <code>Locale</code> object 0120 * for the United States: 0121 * \htmlonly<blockquote>\endhtmlonly 0122 * <pre> 0123 * Locale::getUS() 0124 * </pre> 0125 * \htmlonly</blockquote>\endhtmlonly 0126 * 0127 * <P> 0128 * Once you've created a <code>Locale</code> you can query it for information about 0129 * itself. Use <code>getCountry</code> to get the ISO Country Code and 0130 * <code>getLanguage</code> to get the ISO Language Code. You can 0131 * use <code>getDisplayCountry</code> to get the 0132 * name of the country suitable for displaying to the user. Similarly, 0133 * you can use <code>getDisplayLanguage</code> to get the name of 0134 * the language suitable for displaying to the user. Interestingly, 0135 * the <code>getDisplayXXX</code> methods are themselves locale-sensitive 0136 * and have two versions: one that uses the default locale and one 0137 * that takes a locale as an argument and displays the name or country in 0138 * a language appropriate to that locale. 0139 * 0140 * <P> 0141 * ICU provides a number of classes that perform locale-sensitive 0142 * operations. For example, the <code>NumberFormat</code> class formats 0143 * numbers, currency, or percentages in a locale-sensitive manner. Classes 0144 * such as <code>NumberFormat</code> have a number of convenience methods 0145 * for creating a default object of that type. For example, the 0146 * <code>NumberFormat</code> class provides these three convenience methods 0147 * for creating a default <code>NumberFormat</code> object: 0148 * \htmlonly<blockquote>\endhtmlonly 0149 * <pre> 0150 * UErrorCode success = U_ZERO_ERROR; 0151 * Locale myLocale; 0152 * NumberFormat *nf; 0153 * 0154 * nf = NumberFormat::createInstance( success ); delete nf; 0155 * nf = NumberFormat::createCurrencyInstance( success ); delete nf; 0156 * nf = NumberFormat::createPercentInstance( success ); delete nf; 0157 * </pre> 0158 * \htmlonly</blockquote>\endhtmlonly 0159 * Each of these methods has two variants; one with an explicit locale 0160 * and one without; the latter using the default locale. 0161 * \htmlonly<blockquote>\endhtmlonly 0162 * <pre> 0163 * nf = NumberFormat::createInstance( myLocale, success ); delete nf; 0164 * nf = NumberFormat::createCurrencyInstance( myLocale, success ); delete nf; 0165 * nf = NumberFormat::createPercentInstance( myLocale, success ); delete nf; 0166 * </pre> 0167 * \htmlonly</blockquote>\endhtmlonly 0168 * A <code>Locale</code> is the mechanism for identifying the kind of object 0169 * (<code>NumberFormat</code>) that you would like to get. The locale is 0170 * <STRONG>just</STRONG> a mechanism for identifying objects, 0171 * <STRONG>not</STRONG> a container for the objects themselves. 0172 * 0173 * <P> 0174 * Each class that performs locale-sensitive operations allows you 0175 * to get all the available objects of that type. You can sift 0176 * through these objects by language, country, or variant, 0177 * and use the display names to present a menu to the user. 0178 * For example, you can create a menu of all the collation objects 0179 * suitable for a given language. Such classes implement these 0180 * three class methods: 0181 * \htmlonly<blockquote>\endhtmlonly 0182 * <pre> 0183 * static Locale* getAvailableLocales(int32_t& numLocales) 0184 * static UnicodeString& getDisplayName(const Locale& objectLocale, 0185 * const Locale& displayLocale, 0186 * UnicodeString& displayName) 0187 * static UnicodeString& getDisplayName(const Locale& objectLocale, 0188 * UnicodeString& displayName) 0189 * </pre> 0190 * \htmlonly</blockquote>\endhtmlonly 0191 * 0192 * @stable ICU 2.0 0193 * @see ResourceBundle 0194 */ 0195 class U_COMMON_API Locale : public UObject { 0196 public: 0197 /** Useful constant for the Root locale. @stable ICU 4.4 */ 0198 static const Locale &U_EXPORT2 getRoot(void); 0199 /** Useful constant for this language. @stable ICU 2.0 */ 0200 static const Locale &U_EXPORT2 getEnglish(void); 0201 /** Useful constant for this language. @stable ICU 2.0 */ 0202 static const Locale &U_EXPORT2 getFrench(void); 0203 /** Useful constant for this language. @stable ICU 2.0 */ 0204 static const Locale &U_EXPORT2 getGerman(void); 0205 /** Useful constant for this language. @stable ICU 2.0 */ 0206 static const Locale &U_EXPORT2 getItalian(void); 0207 /** Useful constant for this language. @stable ICU 2.0 */ 0208 static const Locale &U_EXPORT2 getJapanese(void); 0209 /** Useful constant for this language. @stable ICU 2.0 */ 0210 static const Locale &U_EXPORT2 getKorean(void); 0211 /** Useful constant for this language. @stable ICU 2.0 */ 0212 static const Locale &U_EXPORT2 getChinese(void); 0213 /** Useful constant for this language. @stable ICU 2.0 */ 0214 static const Locale &U_EXPORT2 getSimplifiedChinese(void); 0215 /** Useful constant for this language. @stable ICU 2.0 */ 0216 static const Locale &U_EXPORT2 getTraditionalChinese(void); 0217 0218 /** Useful constant for this country/region. @stable ICU 2.0 */ 0219 static const Locale &U_EXPORT2 getFrance(void); 0220 /** Useful constant for this country/region. @stable ICU 2.0 */ 0221 static const Locale &U_EXPORT2 getGermany(void); 0222 /** Useful constant for this country/region. @stable ICU 2.0 */ 0223 static const Locale &U_EXPORT2 getItaly(void); 0224 /** Useful constant for this country/region. @stable ICU 2.0 */ 0225 static const Locale &U_EXPORT2 getJapan(void); 0226 /** Useful constant for this country/region. @stable ICU 2.0 */ 0227 static const Locale &U_EXPORT2 getKorea(void); 0228 /** Useful constant for this country/region. @stable ICU 2.0 */ 0229 static const Locale &U_EXPORT2 getChina(void); 0230 /** Useful constant for this country/region. @stable ICU 2.0 */ 0231 static const Locale &U_EXPORT2 getPRC(void); 0232 /** Useful constant for this country/region. @stable ICU 2.0 */ 0233 static const Locale &U_EXPORT2 getTaiwan(void); 0234 /** Useful constant for this country/region. @stable ICU 2.0 */ 0235 static const Locale &U_EXPORT2 getUK(void); 0236 /** Useful constant for this country/region. @stable ICU 2.0 */ 0237 static const Locale &U_EXPORT2 getUS(void); 0238 /** Useful constant for this country/region. @stable ICU 2.0 */ 0239 static const Locale &U_EXPORT2 getCanada(void); 0240 /** Useful constant for this country/region. @stable ICU 2.0 */ 0241 static const Locale &U_EXPORT2 getCanadaFrench(void); 0242 0243 0244 /** 0245 * Construct a default locale object, a Locale for the default locale ID. 0246 * 0247 * @see getDefault 0248 * @see uloc_getDefault 0249 * @stable ICU 2.0 0250 */ 0251 Locale(); 0252 0253 /** 0254 * Construct a locale from language, country, variant. 0255 * If an error occurs, then the constructed object will be "bogus" 0256 * (isBogus() will return true). 0257 * 0258 * @param language Lowercase two-letter or three-letter ISO-639 code. 0259 * This parameter can instead be an ICU style C locale (e.g. "en_US"), 0260 * but the other parameters must not be used. 0261 * This parameter can be nullptr; if so, 0262 * the locale is initialized to match the current default locale. 0263 * (This is the same as using the default constructor.) 0264 * Please note: The Java Locale class does NOT accept the form 0265 * 'new Locale("en_US")' but only 'new Locale("en","US")' 0266 * 0267 * @param country Uppercase two-letter ISO-3166 code. (optional) 0268 * @param variant Uppercase vendor and browser specific code. See class 0269 * description. (optional) 0270 * @param keywordsAndValues A string consisting of keyword/values pairs, such as 0271 * "collation=phonebook;currency=euro" 0272 * 0273 * @see getDefault 0274 * @see uloc_getDefault 0275 * @stable ICU 2.0 0276 */ 0277 Locale( const char * language, 0278 const char * country = 0, 0279 const char * variant = 0, 0280 const char * keywordsAndValues = 0); 0281 0282 /** 0283 * Initializes a Locale object from another Locale object. 0284 * 0285 * @param other The Locale object being copied in. 0286 * @stable ICU 2.0 0287 */ 0288 Locale(const Locale& other); 0289 0290 /** 0291 * Move constructor; might leave source in bogus state. 0292 * This locale will have the same contents that the source locale had. 0293 * 0294 * @param other The Locale object being moved in. 0295 * @stable ICU 63 0296 */ 0297 Locale(Locale&& other) noexcept; 0298 0299 /** 0300 * Destructor 0301 * @stable ICU 2.0 0302 */ 0303 virtual ~Locale() ; 0304 0305 /** 0306 * Replaces the entire contents of *this with the specified value. 0307 * 0308 * @param other The Locale object being copied in. 0309 * @return *this 0310 * @stable ICU 2.0 0311 */ 0312 Locale& operator=(const Locale& other); 0313 0314 /** 0315 * Move assignment operator; might leave source in bogus state. 0316 * This locale will have the same contents that the source locale had. 0317 * The behavior is undefined if *this and the source are the same object. 0318 * 0319 * @param other The Locale object being moved in. 0320 * @return *this 0321 * @stable ICU 63 0322 */ 0323 Locale& operator=(Locale&& other) noexcept; 0324 0325 /** 0326 * Checks if two locale keys are the same. 0327 * 0328 * @param other The locale key object to be compared with this. 0329 * @return true if the two locale keys are the same, false otherwise. 0330 * @stable ICU 2.0 0331 */ 0332 bool operator==(const Locale& other) const; 0333 0334 /** 0335 * Checks if two locale keys are not the same. 0336 * 0337 * @param other The locale key object to be compared with this. 0338 * @return true if the two locale keys are not the same, false 0339 * otherwise. 0340 * @stable ICU 2.0 0341 */ 0342 inline bool operator!=(const Locale& other) const; 0343 0344 /** 0345 * Clone this object. 0346 * Clones can be used concurrently in multiple threads. 0347 * If an error occurs, then nullptr is returned. 0348 * The caller must delete the clone. 0349 * 0350 * @return a clone of this object 0351 * 0352 * @see getDynamicClassID 0353 * @stable ICU 2.8 0354 */ 0355 Locale *clone() const; 0356 0357 #ifndef U_HIDE_SYSTEM_API 0358 /** 0359 * Common methods of getting the current default Locale. Used for the 0360 * presentation: menus, dialogs, etc. Generally set once when your applet or 0361 * application is initialized, then never reset. (If you do reset the 0362 * default locale, you probably want to reload your GUI, so that the change 0363 * is reflected in your interface.) 0364 * 0365 * More advanced programs will allow users to use different locales for 0366 * different fields, e.g. in a spreadsheet. 0367 * 0368 * Note that the initial setting will match the host system. 0369 * @return a reference to the Locale object for the default locale ID 0370 * @system 0371 * @stable ICU 2.0 0372 */ 0373 static const Locale& U_EXPORT2 getDefault(void); 0374 0375 /** 0376 * Sets the default. Normally set once at the beginning of a process, 0377 * then never reset. 0378 * setDefault() only changes ICU's default locale ID, <strong>not</strong> 0379 * the default locale ID of the runtime environment. 0380 * 0381 * @param newLocale Locale to set to. If nullptr, set to the value obtained 0382 * from the runtime environment. 0383 * @param success The error code. 0384 * @system 0385 * @stable ICU 2.0 0386 */ 0387 static void U_EXPORT2 setDefault(const Locale& newLocale, 0388 UErrorCode& success); 0389 #endif /* U_HIDE_SYSTEM_API */ 0390 0391 /** 0392 * Returns a Locale for the specified BCP47 language tag string. 0393 * If the specified language tag contains any ill-formed subtags, 0394 * the first such subtag and all following subtags are ignored. 0395 * <p> 0396 * This implements the 'Language-Tag' production of BCP 47, and so 0397 * supports legacy language tags (marked as “Type: grandfathered” in BCP 47) 0398 * (regular and irregular) as well as private use language tags. 0399 * 0400 * Private use tags are represented as 'x-whatever', 0401 * and legacy tags are converted to their canonical replacements where they exist. 0402 * 0403 * Note that a few legacy tags have no modern replacement; 0404 * these will be converted using the fallback described in 0405 * the first paragraph, so some information might be lost. 0406 * 0407 * @param tag the input BCP47 language tag. 0408 * @param status error information if creating the Locale failed. 0409 * @return the Locale for the specified BCP47 language tag. 0410 * @stable ICU 63 0411 */ 0412 static Locale U_EXPORT2 forLanguageTag(StringPiece tag, UErrorCode& status); 0413 0414 /** 0415 * Returns a well-formed language tag for this Locale. 0416 * <p> 0417 * <b>Note</b>: Any locale fields which do not satisfy the BCP47 syntax 0418 * requirement will be silently omitted from the result. 0419 * 0420 * If this function fails, partial output may have been written to the sink. 0421 * 0422 * @param sink the output sink receiving the BCP47 language 0423 * tag for this Locale. 0424 * @param status error information if creating the language tag failed. 0425 * @stable ICU 63 0426 */ 0427 void toLanguageTag(ByteSink& sink, UErrorCode& status) const; 0428 0429 /** 0430 * Returns a well-formed language tag for this Locale. 0431 * <p> 0432 * <b>Note</b>: Any locale fields which do not satisfy the BCP47 syntax 0433 * requirement will be silently omitted from the result. 0434 * 0435 * @param status error information if creating the language tag failed. 0436 * @return the BCP47 language tag for this Locale. 0437 * @stable ICU 63 0438 */ 0439 template<typename StringClass> 0440 inline StringClass toLanguageTag(UErrorCode& status) const; 0441 0442 /** 0443 * Creates a locale which has had minimal canonicalization 0444 * as per uloc_getName(). 0445 * @param name The name to create from. If name is null, 0446 * the default Locale is used. 0447 * @return new locale object 0448 * @stable ICU 2.0 0449 * @see uloc_getName 0450 */ 0451 static Locale U_EXPORT2 createFromName(const char *name); 0452 0453 /** 0454 * Creates a locale from the given string after canonicalizing 0455 * the string according to CLDR by calling uloc_canonicalize(). 0456 * @param name the locale ID to create from. Must not be nullptr. 0457 * @return a new locale object corresponding to the given name 0458 * @stable ICU 3.0 0459 * @see uloc_canonicalize 0460 */ 0461 static Locale U_EXPORT2 createCanonical(const char* name); 0462 0463 /** 0464 * Returns the locale's ISO-639 language code. 0465 * @return An alias to the code 0466 * @stable ICU 2.0 0467 */ 0468 inline const char * getLanguage( ) const; 0469 0470 /** 0471 * Returns the locale's ISO-15924 abbreviation script code. 0472 * @return An alias to the code 0473 * @see uscript_getShortName 0474 * @see uscript_getCode 0475 * @stable ICU 2.8 0476 */ 0477 inline const char * getScript( ) const; 0478 0479 /** 0480 * Returns the locale's ISO-3166 country code. 0481 * @return An alias to the code 0482 * @stable ICU 2.0 0483 */ 0484 inline const char * getCountry( ) const; 0485 0486 /** 0487 * Returns the locale's variant code. 0488 * @return An alias to the code 0489 * @stable ICU 2.0 0490 */ 0491 inline const char * getVariant( ) const; 0492 0493 /** 0494 * Returns the programmatic name of the entire locale, with the language, 0495 * country and variant separated by underbars. If a field is missing, up 0496 * to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN", 0497 * "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO" 0498 * @return A pointer to "name". 0499 * @stable ICU 2.0 0500 */ 0501 inline const char * getName() const; 0502 0503 /** 0504 * Returns the programmatic name of the entire locale as getName() would return, 0505 * but without keywords. 0506 * @return A pointer to "name". 0507 * @see getName 0508 * @stable ICU 2.8 0509 */ 0510 const char * getBaseName() const; 0511 0512 /** 0513 * Add the likely subtags for this Locale, per the algorithm described 0514 * in the following CLDR technical report: 0515 * 0516 * http://www.unicode.org/reports/tr35/#Likely_Subtags 0517 * 0518 * If this Locale is already in the maximal form, or not valid, or there is 0519 * no data available for maximization, the Locale will be unchanged. 0520 * 0521 * For example, "und-Zzzz" cannot be maximized, since there is no 0522 * reasonable maximization. 0523 * 0524 * Examples: 0525 * 0526 * "en" maximizes to "en_Latn_US" 0527 * 0528 * "de" maximizes to "de_Latn_US" 0529 * 0530 * "sr" maximizes to "sr_Cyrl_RS" 0531 * 0532 * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) 0533 * 0534 * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.) 0535 * 0536 * @param status error information if maximizing this Locale failed. 0537 * If this Locale is not well-formed, the error code is 0538 * U_ILLEGAL_ARGUMENT_ERROR. 0539 * @stable ICU 63 0540 */ 0541 void addLikelySubtags(UErrorCode& status); 0542 0543 /** 0544 * Minimize the subtags for this Locale, per the algorithm described 0545 * in the following CLDR technical report: 0546 * 0547 * http://www.unicode.org/reports/tr35/#Likely_Subtags 0548 * 0549 * If this Locale is already in the minimal form, or not valid, or there is 0550 * no data available for minimization, the Locale will be unchanged. 0551 * 0552 * Since the minimization algorithm relies on proper maximization, see the 0553 * comments for addLikelySubtags for reasons why there might not be any 0554 * data. 0555 * 0556 * Examples: 0557 * 0558 * "en_Latn_US" minimizes to "en" 0559 * 0560 * "de_Latn_US" minimizes to "de" 0561 * 0562 * "sr_Cyrl_RS" minimizes to "sr" 0563 * 0564 * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the 0565 * script, and minimizing to "zh" would imply "zh_Hans_CN".) 0566 * 0567 * @param status error information if maximizing this Locale failed. 0568 * If this Locale is not well-formed, the error code is 0569 * U_ILLEGAL_ARGUMENT_ERROR. 0570 * @stable ICU 63 0571 */ 0572 void minimizeSubtags(UErrorCode& status); 0573 0574 /** 0575 * Canonicalize the locale ID of this object according to CLDR. 0576 * @param status the status code 0577 * @stable ICU 67 0578 * @see createCanonical 0579 */ 0580 void canonicalize(UErrorCode& status); 0581 0582 /** 0583 * Gets the list of keywords for the specified locale. 0584 * 0585 * @param status the status code 0586 * @return pointer to StringEnumeration class, or nullptr if there are no keywords. 0587 * Client must dispose of it by calling delete. 0588 * @see getKeywords 0589 * @stable ICU 2.8 0590 */ 0591 StringEnumeration * createKeywords(UErrorCode &status) const; 0592 0593 /** 0594 * Gets the list of Unicode keywords for the specified locale. 0595 * 0596 * @param status the status code 0597 * @return pointer to StringEnumeration class, or nullptr if there are no keywords. 0598 * Client must dispose of it by calling delete. 0599 * @see getUnicodeKeywords 0600 * @stable ICU 63 0601 */ 0602 StringEnumeration * createUnicodeKeywords(UErrorCode &status) const; 0603 0604 /** 0605 * Gets the set of keywords for this Locale. 0606 * 0607 * A wrapper to call createKeywords() and write the resulting 0608 * keywords as standard strings (or compatible objects) into any kind of 0609 * container that can be written to by an STL style output iterator. 0610 * 0611 * @param iterator an STL style output iterator to write the keywords to. 0612 * @param status error information if creating set of keywords failed. 0613 * @stable ICU 63 0614 */ 0615 template<typename StringClass, typename OutputIterator> 0616 inline void getKeywords(OutputIterator iterator, UErrorCode& status) const; 0617 0618 /** 0619 * Gets the set of Unicode keywords for this Locale. 0620 * 0621 * A wrapper to call createUnicodeKeywords() and write the resulting 0622 * keywords as standard strings (or compatible objects) into any kind of 0623 * container that can be written to by an STL style output iterator. 0624 * 0625 * @param iterator an STL style output iterator to write the keywords to. 0626 * @param status error information if creating set of keywords failed. 0627 * @stable ICU 63 0628 */ 0629 template<typename StringClass, typename OutputIterator> 0630 inline void getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const; 0631 0632 /** 0633 * Gets the value for a keyword. 0634 * 0635 * This uses legacy keyword=value pairs, like "collation=phonebook". 0636 * 0637 * ICU4C doesn't do automatic conversion between legacy and Unicode 0638 * keywords and values in getters and setters (as opposed to ICU4J). 0639 * 0640 * @param keywordName name of the keyword for which we want the value. Case insensitive. 0641 * @param buffer The buffer to receive the keyword value. 0642 * @param bufferCapacity The capacity of receiving buffer 0643 * @param status Returns any error information while performing this operation. 0644 * @return the length of the keyword value 0645 * 0646 * @stable ICU 2.8 0647 */ 0648 int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const; 0649 0650 /** 0651 * Gets the value for a keyword. 0652 * 0653 * This uses legacy keyword=value pairs, like "collation=phonebook". 0654 * 0655 * ICU4C doesn't do automatic conversion between legacy and Unicode 0656 * keywords and values in getters and setters (as opposed to ICU4J). 0657 * 0658 * @param keywordName name of the keyword for which we want the value. 0659 * @param sink the sink to receive the keyword value. 0660 * @param status error information if getting the value failed. 0661 * @stable ICU 63 0662 */ 0663 void getKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const; 0664 0665 /** 0666 * Gets the value for a keyword. 0667 * 0668 * This uses legacy keyword=value pairs, like "collation=phonebook". 0669 * 0670 * ICU4C doesn't do automatic conversion between legacy and Unicode 0671 * keywords and values in getters and setters (as opposed to ICU4J). 0672 * 0673 * @param keywordName name of the keyword for which we want the value. 0674 * @param status error information if getting the value failed. 0675 * @return the keyword value. 0676 * @stable ICU 63 0677 */ 0678 template<typename StringClass> 0679 inline StringClass getKeywordValue(StringPiece keywordName, UErrorCode& status) const; 0680 0681 /** 0682 * Gets the Unicode value for a Unicode keyword. 0683 * 0684 * This uses Unicode key-value pairs, like "co-phonebk". 0685 * 0686 * ICU4C doesn't do automatic conversion between legacy and Unicode 0687 * keywords and values in getters and setters (as opposed to ICU4J). 0688 * 0689 * @param keywordName name of the keyword for which we want the value. 0690 * @param sink the sink to receive the keyword value. 0691 * @param status error information if getting the value failed. 0692 * @stable ICU 63 0693 */ 0694 void getUnicodeKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const; 0695 0696 /** 0697 * Gets the Unicode value for a Unicode keyword. 0698 * 0699 * This uses Unicode key-value pairs, like "co-phonebk". 0700 * 0701 * ICU4C doesn't do automatic conversion between legacy and Unicode 0702 * keywords and values in getters and setters (as opposed to ICU4J). 0703 * 0704 * @param keywordName name of the keyword for which we want the value. 0705 * @param status error information if getting the value failed. 0706 * @return the keyword value. 0707 * @stable ICU 63 0708 */ 0709 template<typename StringClass> 0710 inline StringClass getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const; 0711 0712 /** 0713 * Sets or removes the value for a keyword. 0714 * 0715 * For removing all keywords, use getBaseName(), 0716 * and construct a new Locale if it differs from getName(). 0717 * 0718 * This uses legacy keyword=value pairs, like "collation=phonebook". 0719 * 0720 * ICU4C doesn't do automatic conversion between legacy and Unicode 0721 * keywords and values in getters and setters (as opposed to ICU4J). 0722 * 0723 * @param keywordName name of the keyword to be set. Case insensitive. 0724 * @param keywordValue value of the keyword to be set. If 0-length or 0725 * nullptr, will result in the keyword being removed. No error is given if 0726 * that keyword does not exist. 0727 * @param status Returns any error information while performing this operation. 0728 * 0729 * @stable ICU 49 0730 */ 0731 void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status); 0732 0733 /** 0734 * Sets or removes the value for a keyword. 0735 * 0736 * For removing all keywords, use getBaseName(), 0737 * and construct a new Locale if it differs from getName(). 0738 * 0739 * This uses legacy keyword=value pairs, like "collation=phonebook". 0740 * 0741 * ICU4C doesn't do automatic conversion between legacy and Unicode 0742 * keywords and values in getters and setters (as opposed to ICU4J). 0743 * 0744 * @param keywordName name of the keyword to be set. 0745 * @param keywordValue value of the keyword to be set. If 0-length or 0746 * nullptr, will result in the keyword being removed. No error is given if 0747 * that keyword does not exist. 0748 * @param status Returns any error information while performing this operation. 0749 * @stable ICU 63 0750 */ 0751 void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode& status); 0752 0753 /** 0754 * Sets or removes the Unicode value for a Unicode keyword. 0755 * 0756 * For removing all keywords, use getBaseName(), 0757 * and construct a new Locale if it differs from getName(). 0758 * 0759 * This uses Unicode key-value pairs, like "co-phonebk". 0760 * 0761 * ICU4C doesn't do automatic conversion between legacy and Unicode 0762 * keywords and values in getters and setters (as opposed to ICU4J). 0763 * 0764 * @param keywordName name of the keyword to be set. 0765 * @param keywordValue value of the keyword to be set. If 0-length or 0766 * nullptr, will result in the keyword being removed. No error is given if 0767 * that keyword does not exist. 0768 * @param status Returns any error information while performing this operation. 0769 * @stable ICU 63 0770 */ 0771 void setUnicodeKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode& status); 0772 0773 /** 0774 * returns the locale's three-letter language code, as specified 0775 * in ISO draft standard ISO-639-2. 0776 * @return An alias to the code, or an empty string 0777 * @stable ICU 2.0 0778 */ 0779 const char * getISO3Language() const; 0780 0781 /** 0782 * Fills in "name" with the locale's three-letter ISO-3166 country code. 0783 * @return An alias to the code, or an empty string 0784 * @stable ICU 2.0 0785 */ 0786 const char * getISO3Country() const; 0787 0788 /** 0789 * Returns the Windows LCID value corresponding to this locale. 0790 * This value is stored in the resource data for the locale as a one-to-four-digit 0791 * hexadecimal number. If the resource is missing, in the wrong format, or 0792 * there is no Windows LCID value that corresponds to this locale, returns 0. 0793 * @stable ICU 2.0 0794 */ 0795 uint32_t getLCID(void) const; 0796 0797 /** 0798 * Returns whether this locale's script is written right-to-left. 0799 * If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags(). 0800 * If no likely script is known, then false is returned. 0801 * 0802 * A script is right-to-left according to the CLDR script metadata 0803 * which corresponds to whether the script's letters have Bidi_Class=R or AL. 0804 * 0805 * Returns true for "ar" and "en-Hebr", false for "zh" and "fa-Cyrl". 0806 * 0807 * @return true if the locale's script is written right-to-left 0808 * @stable ICU 54 0809 */ 0810 UBool isRightToLeft() const; 0811 0812 /** 0813 * Fills in "dispLang" with the name of this locale's language in a format suitable for 0814 * user display in the default locale. For example, if the locale's language code is 0815 * "fr" and the default locale's language code is "en", this function would set 0816 * dispLang to "French". 0817 * @param dispLang Receives the language's display name. 0818 * @return A reference to "dispLang". 0819 * @stable ICU 2.0 0820 */ 0821 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const; 0822 0823 /** 0824 * Fills in "dispLang" with the name of this locale's language in a format suitable for 0825 * user display in the locale specified by "displayLocale". For example, if the locale's 0826 * language code is "en" and displayLocale's language code is "fr", this function would set 0827 * dispLang to "Anglais". 0828 * @param displayLocale Specifies the locale to be used to display the name. In other words, 0829 * if the locale's language code is "en", passing Locale::getFrench() for 0830 * displayLocale would result in "Anglais", while passing Locale::getGerman() 0831 * for displayLocale would result in "Englisch". 0832 * @param dispLang Receives the language's display name. 0833 * @return A reference to "dispLang". 0834 * @stable ICU 2.0 0835 */ 0836 UnicodeString& getDisplayLanguage( const Locale& displayLocale, 0837 UnicodeString& dispLang) const; 0838 0839 /** 0840 * Fills in "dispScript" with the name of this locale's script in a format suitable 0841 * for user display in the default locale. For example, if the locale's script code 0842 * is "LATN" and the default locale's language code is "en", this function would set 0843 * dispScript to "Latin". 0844 * @param dispScript Receives the scripts's display name. 0845 * @return A reference to "dispScript". 0846 * @stable ICU 2.8 0847 */ 0848 UnicodeString& getDisplayScript( UnicodeString& dispScript) const; 0849 0850 /** 0851 * Fills in "dispScript" with the name of this locale's country in a format suitable 0852 * for user display in the locale specified by "displayLocale". For example, if the locale's 0853 * script code is "LATN" and displayLocale's language code is "en", this function would set 0854 * dispScript to "Latin". 0855 * @param displayLocale Specifies the locale to be used to display the name. In other 0856 * words, if the locale's script code is "LATN", passing 0857 * Locale::getFrench() for displayLocale would result in "", while 0858 * passing Locale::getGerman() for displayLocale would result in 0859 * "". 0860 * @param dispScript Receives the scripts's display name. 0861 * @return A reference to "dispScript". 0862 * @stable ICU 2.8 0863 */ 0864 UnicodeString& getDisplayScript( const Locale& displayLocale, 0865 UnicodeString& dispScript) const; 0866 0867 /** 0868 * Fills in "dispCountry" with the name of this locale's country in a format suitable 0869 * for user display in the default locale. For example, if the locale's country code 0870 * is "FR" and the default locale's language code is "en", this function would set 0871 * dispCountry to "France". 0872 * @param dispCountry Receives the country's display name. 0873 * @return A reference to "dispCountry". 0874 * @stable ICU 2.0 0875 */ 0876 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const; 0877 0878 /** 0879 * Fills in "dispCountry" with the name of this locale's country in a format suitable 0880 * for user display in the locale specified by "displayLocale". For example, if the locale's 0881 * country code is "US" and displayLocale's language code is "fr", this function would set 0882 * dispCountry to "États-Unis". 0883 * @param displayLocale Specifies the locale to be used to display the name. In other 0884 * words, if the locale's country code is "US", passing 0885 * Locale::getFrench() for displayLocale would result in "États-Unis", while 0886 * passing Locale::getGerman() for displayLocale would result in 0887 * "Vereinigte Staaten". 0888 * @param dispCountry Receives the country's display name. 0889 * @return A reference to "dispCountry". 0890 * @stable ICU 2.0 0891 */ 0892 UnicodeString& getDisplayCountry( const Locale& displayLocale, 0893 UnicodeString& dispCountry) const; 0894 0895 /** 0896 * Fills in "dispVar" with the name of this locale's variant code in a format suitable 0897 * for user display in the default locale. 0898 * @param dispVar Receives the variant's name. 0899 * @return A reference to "dispVar". 0900 * @stable ICU 2.0 0901 */ 0902 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const; 0903 0904 /** 0905 * Fills in "dispVar" with the name of this locale's variant code in a format 0906 * suitable for user display in the locale specified by "displayLocale". 0907 * @param displayLocale Specifies the locale to be used to display the name. 0908 * @param dispVar Receives the variant's display name. 0909 * @return A reference to "dispVar". 0910 * @stable ICU 2.0 0911 */ 0912 UnicodeString& getDisplayVariant( const Locale& displayLocale, 0913 UnicodeString& dispVar) const; 0914 0915 /** 0916 * Fills in "name" with the name of this locale in a format suitable for user display 0917 * in the default locale. This function uses getDisplayLanguage(), getDisplayCountry(), 0918 * and getDisplayVariant() to do its work, and outputs the display name in the format 0919 * "language (country[,variant])". For example, if the default locale is en_US, then 0920 * fr_FR's display name would be "French (France)", and es_MX_Traditional's display name 0921 * would be "Spanish (Mexico,Traditional)". 0922 * @param name Receives the locale's display name. 0923 * @return A reference to "name". 0924 * @stable ICU 2.0 0925 */ 0926 UnicodeString& getDisplayName( UnicodeString& name) const; 0927 0928 /** 0929 * Fills in "name" with the name of this locale in a format suitable for user display 0930 * in the locale specified by "displayLocale". This function uses getDisplayLanguage(), 0931 * getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display 0932 * name in the format "language (country[,variant])". For example, if displayLocale is 0933 * fr_FR, then en_US's display name would be "Anglais (États-Unis)", and no_NO_NY's 0934 * display name would be "norvégien (Norvège,NY)". 0935 * @param displayLocale Specifies the locale to be used to display the name. 0936 * @param name Receives the locale's display name. 0937 * @return A reference to "name". 0938 * @stable ICU 2.0 0939 */ 0940 UnicodeString& getDisplayName( const Locale& displayLocale, 0941 UnicodeString& name) const; 0942 0943 /** 0944 * Generates a hash code for the locale. 0945 * @stable ICU 2.0 0946 */ 0947 int32_t hashCode(void) const; 0948 0949 /** 0950 * Sets the locale to bogus 0951 * A bogus locale represents a non-existing locale associated 0952 * with services that can be instantiated from non-locale data 0953 * in addition to locale (for example, collation can be 0954 * instantiated from a locale and from a rule set). 0955 * @stable ICU 2.1 0956 */ 0957 void setToBogus(); 0958 0959 /** 0960 * Gets the bogus state. Locale object can be bogus if it doesn't exist 0961 * @return false if it is a real locale, true if it is a bogus locale 0962 * @stable ICU 2.1 0963 */ 0964 inline UBool isBogus(void) const; 0965 0966 /** 0967 * Returns a list of all installed locales. 0968 * @param count Receives the number of locales in the list. 0969 * @return A pointer to an array of Locale objects. This array is the list 0970 * of all locales with installed resource files. The called does NOT 0971 * get ownership of this list, and must NOT delete it. 0972 * @stable ICU 2.0 0973 */ 0974 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); 0975 0976 /** 0977 * Gets a list of all available 2-letter country codes defined in ISO 3166. This is a 0978 * pointer to an array of pointers to arrays of char. All of these pointers are 0979 * owned by ICU-- do not delete them, and do not write through them. The array is 0980 * terminated with a null pointer. 0981 * @return a list of all available country codes 0982 * @stable ICU 2.0 0983 */ 0984 static const char* const* U_EXPORT2 getISOCountries(); 0985 0986 /** 0987 * Returns a list of all unique language codes defined in ISO 639. 0988 * They can be 2 or 3 letter codes, as defined by 0989 * <a href="https://www.ietf.org/rfc/bcp/bcp47.html#section-2.2.1"> 0990 * BCP 47, section 2.2.1</a>. This is a pointer 0991 * to an array of pointers to arrays of char. All of these pointers are owned 0992 * by ICU-- do not delete them, and do not write through them. The array is 0993 * terminated with a null pointer. 0994 * @return a list of all available language codes 0995 * @stable ICU 2.0 0996 */ 0997 static const char* const* U_EXPORT2 getISOLanguages(); 0998 0999 /** 1000 * ICU "poor man's RTTI", returns a UClassID for this class. 1001 * 1002 * @stable ICU 2.2 1003 */ 1004 static UClassID U_EXPORT2 getStaticClassID(); 1005 1006 /** 1007 * ICU "poor man's RTTI", returns a UClassID for the actual class. 1008 * 1009 * @stable ICU 2.2 1010 */ 1011 virtual UClassID getDynamicClassID() const override; 1012 1013 /** 1014 * A Locale iterator interface similar to a Java Iterator<Locale>. 1015 * @stable ICU 65 1016 */ 1017 class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ { 1018 public: 1019 /** @stable ICU 65 */ 1020 virtual ~Iterator(); 1021 1022 /** 1023 * @return true if next() can be called again. 1024 * @stable ICU 65 1025 */ 1026 virtual UBool hasNext() const = 0; 1027 1028 /** 1029 * @return the next locale. 1030 * @stable ICU 65 1031 */ 1032 virtual const Locale &next() = 0; 1033 }; 1034 1035 /** 1036 * A generic Locale iterator implementation over Locale input iterators. 1037 * @stable ICU 65 1038 */ 1039 template<typename Iter> 1040 class RangeIterator : public Iterator, public UMemory { 1041 public: 1042 /** 1043 * Constructs an iterator from a begin/end range. 1044 * Each of the iterator parameter values must be an 1045 * input iterator whose value is convertible to const Locale &. 1046 * 1047 * @param begin Start of range. 1048 * @param end Exclusive end of range. 1049 * @stable ICU 65 1050 */ 1051 RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {} 1052 1053 /** 1054 * @return true if next() can be called again. 1055 * @stable ICU 65 1056 */ 1057 UBool hasNext() const override { return it_ != end_; } 1058 1059 /** 1060 * @return the next locale. 1061 * @stable ICU 65 1062 */ 1063 const Locale &next() override { return *it_++; } 1064 1065 private: 1066 Iter it_; 1067 const Iter end_; 1068 }; 1069 1070 /** 1071 * A generic Locale iterator implementation over Locale input iterators. 1072 * Calls the converter to convert each *begin to a const Locale &. 1073 * @stable ICU 65 1074 */ 1075 template<typename Iter, typename Conv> 1076 class ConvertingIterator : public Iterator, public UMemory { 1077 public: 1078 /** 1079 * Constructs an iterator from a begin/end range. 1080 * Each of the iterator parameter values must be an 1081 * input iterator whose value the converter converts to const Locale &. 1082 * 1083 * @param begin Start of range. 1084 * @param end Exclusive end of range. 1085 * @param converter Converter from *begin to const Locale & or compatible. 1086 * @stable ICU 65 1087 */ 1088 ConvertingIterator(Iter begin, Iter end, Conv converter) : 1089 it_(begin), end_(end), converter_(converter) {} 1090 1091 /** 1092 * @return true if next() can be called again. 1093 * @stable ICU 65 1094 */ 1095 UBool hasNext() const override { return it_ != end_; } 1096 1097 /** 1098 * @return the next locale. 1099 * @stable ICU 65 1100 */ 1101 const Locale &next() override { return converter_(*it_++); } 1102 1103 private: 1104 Iter it_; 1105 const Iter end_; 1106 Conv converter_; 1107 }; 1108 1109 protected: /* only protected for testing purposes. DO NOT USE. */ 1110 #ifndef U_HIDE_INTERNAL_API 1111 /** 1112 * Set this from a single POSIX style locale string. 1113 * @internal 1114 */ 1115 void setFromPOSIXID(const char *posixID); 1116 /** 1117 * Minimize the subtags for this Locale, per the algorithm described 1118 * @param favorScript favor to keep script if true, to keep region if false. 1119 * @param status error information if maximizing this Locale failed. 1120 * If this Locale is not well-formed, the error code is 1121 * U_ILLEGAL_ARGUMENT_ERROR. 1122 * @internal 1123 */ 1124 void minimizeSubtags(bool favorScript, UErrorCode& status); 1125 #endif /* U_HIDE_INTERNAL_API */ 1126 1127 private: 1128 /** 1129 * Initialize the locale object with a new name. 1130 * Was deprecated - used in implementation - moved internal 1131 * 1132 * @param cLocaleID The new locale name. 1133 * @param canonicalize whether to call uloc_canonicalize on cLocaleID 1134 */ 1135 Locale& init(const char* cLocaleID, UBool canonicalize); 1136 1137 /* 1138 * Internal constructor to allow construction of a locale object with 1139 * NO side effects. (Default constructor tries to get 1140 * the default locale.) 1141 */ 1142 enum ELocaleType { 1143 eBOGUS 1144 }; 1145 Locale(ELocaleType); 1146 1147 /** 1148 * Initialize the locale cache for commonly used locales 1149 */ 1150 static Locale *getLocaleCache(void); 1151 1152 char language[ULOC_LANG_CAPACITY]; 1153 char script[ULOC_SCRIPT_CAPACITY]; 1154 char country[ULOC_COUNTRY_CAPACITY]; 1155 int32_t variantBegin; 1156 char* fullName; 1157 char fullNameBuffer[ULOC_FULLNAME_CAPACITY]; 1158 // name without keywords 1159 char* baseName; 1160 void initBaseName(UErrorCode& status); 1161 1162 UBool fIsBogus; 1163 1164 static const Locale &getLocale(int locid); 1165 1166 /** 1167 * A friend to allow the default locale to be set by either the C or C++ API. 1168 * @internal (private) 1169 */ 1170 friend Locale *locale_set_default_internal(const char *, UErrorCode& status); 1171 1172 /** 1173 * @internal (private) 1174 */ 1175 friend void U_CALLCONV locale_available_init(); 1176 }; 1177 1178 inline bool 1179 Locale::operator!=(const Locale& other) const 1180 { 1181 return !operator==(other); 1182 } 1183 1184 template<typename StringClass> inline StringClass 1185 Locale::toLanguageTag(UErrorCode& status) const 1186 { 1187 StringClass result; 1188 StringByteSink<StringClass> sink(&result); 1189 toLanguageTag(sink, status); 1190 return result; 1191 } 1192 1193 inline const char * 1194 Locale::getCountry() const 1195 { 1196 return country; 1197 } 1198 1199 inline const char * 1200 Locale::getLanguage() const 1201 { 1202 return language; 1203 } 1204 1205 inline const char * 1206 Locale::getScript() const 1207 { 1208 return script; 1209 } 1210 1211 inline const char * 1212 Locale::getVariant() const 1213 { 1214 return &baseName[variantBegin]; 1215 } 1216 1217 inline const char * 1218 Locale::getName() const 1219 { 1220 return fullName; 1221 } 1222 1223 template<typename StringClass, typename OutputIterator> inline void 1224 Locale::getKeywords(OutputIterator iterator, UErrorCode& status) const 1225 { 1226 LocalPointer<StringEnumeration> keys(createKeywords(status)); 1227 if (U_FAILURE(status) || keys.isNull()) { 1228 return; 1229 } 1230 for (;;) { 1231 int32_t resultLength; 1232 const char* buffer = keys->next(&resultLength, status); 1233 if (U_FAILURE(status) || buffer == nullptr) { 1234 return; 1235 } 1236 *iterator++ = StringClass(buffer, resultLength); 1237 } 1238 } 1239 1240 template<typename StringClass, typename OutputIterator> inline void 1241 Locale::getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const 1242 { 1243 LocalPointer<StringEnumeration> keys(createUnicodeKeywords(status)); 1244 if (U_FAILURE(status) || keys.isNull()) { 1245 return; 1246 } 1247 for (;;) { 1248 int32_t resultLength; 1249 const char* buffer = keys->next(&resultLength, status); 1250 if (U_FAILURE(status) || buffer == nullptr) { 1251 return; 1252 } 1253 *iterator++ = StringClass(buffer, resultLength); 1254 } 1255 } 1256 1257 template<typename StringClass> inline StringClass 1258 Locale::getKeywordValue(StringPiece keywordName, UErrorCode& status) const 1259 { 1260 StringClass result; 1261 StringByteSink<StringClass> sink(&result); 1262 getKeywordValue(keywordName, sink, status); 1263 return result; 1264 } 1265 1266 template<typename StringClass> inline StringClass 1267 Locale::getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const 1268 { 1269 StringClass result; 1270 StringByteSink<StringClass> sink(&result); 1271 getUnicodeKeywordValue(keywordName, sink, status); 1272 return result; 1273 } 1274 1275 inline UBool 1276 Locale::isBogus(void) const { 1277 return fIsBogus; 1278 } 1279 1280 U_NAMESPACE_END 1281 1282 #endif /* U_SHOW_CPLUSPLUS_API */ 1283 1284 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |