|
||||
Warning, file /include/unicode/uloc.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 * Copyright (C) 1997-2016, International Business Machines 0006 * Corporation and others. All Rights Reserved. 0007 ********************************************************************** 0008 * 0009 * File ULOC.H 0010 * 0011 * Modification History: 0012 * 0013 * Date Name Description 0014 * 04/01/97 aliu Creation. 0015 * 08/22/98 stephen JDK 1.2 sync. 0016 * 12/08/98 rtg New C API for Locale 0017 * 03/30/99 damiba overhaul 0018 * 03/31/99 helena Javadoc for uloc functions. 0019 * 04/15/99 Madhu Updated Javadoc 0020 ******************************************************************************** 0021 */ 0022 0023 #ifndef ULOC_H 0024 #define ULOC_H 0025 0026 #include "unicode/utypes.h" 0027 #include "unicode/uenum.h" 0028 0029 /** 0030 * \file 0031 * \brief C API: Locale ID functionality similar to C++ class Locale 0032 * 0033 * <h2> ULoc C API for Locale </h2> 0034 * A <code>Locale</code> represents a specific geographical, political, 0035 * or cultural region. An operation that requires a <code>Locale</code> to perform 0036 * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code> 0037 * to tailor information for the user. For example, displaying a number 0038 * is a locale-sensitive operation--the number should be formatted 0039 * according to the customs/conventions of the user's native country, 0040 * region, or culture. In the C APIs, a locales is simply a const char string. 0041 * 0042 * <P> 0043 * You create a <code>Locale</code> with one of the three options listed below. 0044 * Each of the component is separated by '_' in the locale string. 0045 * \htmlonly<blockquote>\endhtmlonly 0046 * <pre> 0047 * \code 0048 * newLanguage 0049 * 0050 * newLanguage + newCountry 0051 * 0052 * newLanguage + newCountry + newVariant 0053 * \endcode 0054 * </pre> 0055 * \htmlonly</blockquote>\endhtmlonly 0056 * The first option is a valid <STRONG>ISO 0057 * Language Code.</STRONG> These codes are the lower-case two-letter 0058 * codes as defined by ISO-639. 0059 * You can find a full list of these codes at a number of sites, such as: 0060 * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> 0061 * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</a> 0062 * 0063 * <P> 0064 * The second option includes an additional <STRONG>ISO Country 0065 * Code.</STRONG> These codes are the upper-case two-letter codes 0066 * as defined by ISO-3166. 0067 * You can find a full list of these codes at a number of sites, such as: 0068 * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> 0069 * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</a> 0070 * 0071 * <P> 0072 * The third option requires another additional information--the 0073 * <STRONG>Variant.</STRONG> 0074 * The Variant codes are vendor and browser-specific. 0075 * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. 0076 * Where there are two variants, separate them with an underscore, and 0077 * put the most important one first. For 0078 * example, a Traditional Spanish collation might be referenced, with 0079 * "ES", "ES", "Traditional_WIN". 0080 * 0081 * <P> 0082 * Because a <code>Locale</code> is just an identifier for a region, 0083 * no validity check is performed when you specify a <code>Locale</code>. 0084 * If you want to see whether particular resources are available for the 0085 * <code>Locale</code> you asked for, you must query those resources. For 0086 * example, ask the <code>UNumberFormat</code> for the locales it supports 0087 * using its <code>getAvailable</code> method. 0088 * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular 0089 * locale, you get back the best available match, not necessarily 0090 * precisely what you asked for. For more information, look at 0091 * <code>UResourceBundle</code>. 0092 * 0093 * <P> 0094 * The <code>Locale</code> provides a number of convenient constants 0095 * that you can use to specify the commonly used 0096 * locales. For example, the following refers to a locale 0097 * for the United States: 0098 * \htmlonly<blockquote>\endhtmlonly 0099 * <pre> 0100 * \code 0101 * ULOC_US 0102 * \endcode 0103 * </pre> 0104 * \htmlonly</blockquote>\endhtmlonly 0105 * 0106 * <P> 0107 * Once you've specified a locale you can query it for information about 0108 * itself. Use <code>uloc_getCountry</code> to get the ISO Country Code and 0109 * <code>uloc_getLanguage</code> to get the ISO Language Code. You can 0110 * use <code>uloc_getDisplayCountry</code> to get the 0111 * name of the country suitable for displaying to the user. Similarly, 0112 * you can use <code>uloc_getDisplayLanguage</code> to get the name of 0113 * the language suitable for displaying to the user. Interestingly, 0114 * the <code>uloc_getDisplayXXX</code> methods are themselves locale-sensitive 0115 * and have two versions: one that uses the default locale and one 0116 * that takes a locale as an argument and displays the name or country in 0117 * a language appropriate to that locale. 0118 * 0119 * <P> 0120 * The ICU provides a number of services that perform locale-sensitive 0121 * operations. For example, the <code>unum_xxx</code> functions format 0122 * numbers, currency, or percentages in a locale-sensitive manner. 0123 * </P> 0124 * \htmlonly<blockquote>\endhtmlonly 0125 * <pre> 0126 * \code 0127 * UErrorCode success = U_ZERO_ERROR; 0128 * UNumberFormat *nf; 0129 * const char* myLocale = "fr_FR"; 0130 * 0131 * nf = unum_open( UNUM_DEFAULT, NULL, success ); 0132 * unum_close(nf); 0133 * nf = unum_open( UNUM_CURRENCY, NULL, success ); 0134 * unum_close(nf); 0135 * nf = unum_open( UNUM_PERCENT, NULL, success ); 0136 * unum_close(nf); 0137 * \endcode 0138 * </pre> 0139 * \htmlonly</blockquote>\endhtmlonly 0140 * Each of these methods has two variants; one with an explicit locale 0141 * and one without; the latter using the default locale. 0142 * \htmlonly<blockquote>\endhtmlonly 0143 * <pre> 0144 * \code 0145 * 0146 * nf = unum_open( UNUM_DEFAULT, myLocale, success ); 0147 * unum_close(nf); 0148 * nf = unum_open( UNUM_CURRENCY, myLocale, success ); 0149 * unum_close(nf); 0150 * nf = unum_open( UNUM_PERCENT, myLocale, success ); 0151 * unum_close(nf); 0152 * \endcode 0153 * </pre> 0154 * \htmlonly</blockquote>\endhtmlonly 0155 * A <code>Locale</code> is the mechanism for identifying the kind of services 0156 * (<code>UNumberFormat</code>) that you would like to get. The locale is 0157 * <STRONG>just</STRONG> a mechanism for identifying these services. 0158 * 0159 * <P> 0160 * Each international service that performs locale-sensitive operations 0161 * allows you 0162 * to get all the available objects of that type. You can sift 0163 * through these objects by language, country, or variant, 0164 * and use the display names to present a menu to the user. 0165 * For example, you can create a menu of all the collation objects 0166 * suitable for a given language. Such classes implement these 0167 * three class methods: 0168 * \htmlonly<blockquote>\endhtmlonly 0169 * <pre> 0170 * \code 0171 * const char* uloc_getAvailable(int32_t index); 0172 * int32_t uloc_countAvailable(); 0173 * int32_t 0174 * uloc_getDisplayName(const char* localeID, 0175 * const char* inLocaleID, 0176 * UChar* result, 0177 * int32_t maxResultSize, 0178 * UErrorCode* err); 0179 * 0180 * \endcode 0181 * </pre> 0182 * \htmlonly</blockquote>\endhtmlonly 0183 * <P> 0184 * Concerning POSIX/RFC1766 Locale IDs, 0185 * the getLanguage/getCountry/getVariant/getName functions do understand 0186 * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT 0187 * and if there is not an ICU-stype variant, uloc_getVariant() for example 0188 * will return the one listed after the \@at sign. As well, the hyphen 0189 * "-" is recognized as a country/variant separator similarly to RFC1766. 0190 * So for example, "en-us" will be interpreted as en_US. 0191 * As a result, uloc_getName() is far from a no-op, and will have the 0192 * effect of converting POSIX/RFC1766 IDs into ICU form, although it does 0193 * NOT map any of the actual codes (i.e. russian->ru) in any way. 0194 * Applications should call uloc_getName() at the point where a locale ID 0195 * is coming from an external source (user entry, OS, web browser) 0196 * and pass the resulting string to other ICU functions. For example, 0197 * don't use de-de\@EURO as an argument to resourcebundle. 0198 * 0199 * @see UResourceBundle 0200 */ 0201 0202 /** Useful constant for this language. @stable ICU 2.0 */ 0203 #define ULOC_CHINESE "zh" 0204 /** Useful constant for this language. @stable ICU 2.0 */ 0205 #define ULOC_ENGLISH "en" 0206 /** Useful constant for this language. @stable ICU 2.0 */ 0207 #define ULOC_FRENCH "fr" 0208 /** Useful constant for this language. @stable ICU 2.0 */ 0209 #define ULOC_GERMAN "de" 0210 /** Useful constant for this language. @stable ICU 2.0 */ 0211 #define ULOC_ITALIAN "it" 0212 /** Useful constant for this language. @stable ICU 2.0 */ 0213 #define ULOC_JAPANESE "ja" 0214 /** Useful constant for this language. @stable ICU 2.0 */ 0215 #define ULOC_KOREAN "ko" 0216 /** Useful constant for this language. @stable ICU 2.0 */ 0217 #define ULOC_SIMPLIFIED_CHINESE "zh_CN" 0218 /** Useful constant for this language. @stable ICU 2.0 */ 0219 #define ULOC_TRADITIONAL_CHINESE "zh_TW" 0220 0221 /** Useful constant for this country/region. @stable ICU 2.0 */ 0222 #define ULOC_CANADA "en_CA" 0223 /** Useful constant for this country/region. @stable ICU 2.0 */ 0224 #define ULOC_CANADA_FRENCH "fr_CA" 0225 /** Useful constant for this country/region. @stable ICU 2.0 */ 0226 #define ULOC_CHINA "zh_CN" 0227 /** Useful constant for this country/region. @stable ICU 2.0 */ 0228 #define ULOC_PRC "zh_CN" 0229 /** Useful constant for this country/region. @stable ICU 2.0 */ 0230 #define ULOC_FRANCE "fr_FR" 0231 /** Useful constant for this country/region. @stable ICU 2.0 */ 0232 #define ULOC_GERMANY "de_DE" 0233 /** Useful constant for this country/region. @stable ICU 2.0 */ 0234 #define ULOC_ITALY "it_IT" 0235 /** Useful constant for this country/region. @stable ICU 2.0 */ 0236 #define ULOC_JAPAN "ja_JP" 0237 /** Useful constant for this country/region. @stable ICU 2.0 */ 0238 #define ULOC_KOREA "ko_KR" 0239 /** Useful constant for this country/region. @stable ICU 2.0 */ 0240 #define ULOC_TAIWAN "zh_TW" 0241 /** Useful constant for this country/region. @stable ICU 2.0 */ 0242 #define ULOC_UK "en_GB" 0243 /** Useful constant for this country/region. @stable ICU 2.0 */ 0244 #define ULOC_US "en_US" 0245 0246 /** 0247 * Useful constant for the maximum size of the language part of a locale ID. 0248 * (including the terminating NULL). 0249 * @stable ICU 2.0 0250 */ 0251 #define ULOC_LANG_CAPACITY 12 0252 0253 /** 0254 * Useful constant for the maximum size of the country part of a locale ID 0255 * (including the terminating NULL). 0256 * @stable ICU 2.0 0257 */ 0258 #define ULOC_COUNTRY_CAPACITY 4 0259 /** 0260 * Useful constant for the maximum size of the whole locale ID 0261 * (including the terminating NULL and all keywords). 0262 * @stable ICU 2.0 0263 */ 0264 #define ULOC_FULLNAME_CAPACITY 157 0265 0266 /** 0267 * Useful constant for the maximum size of the script part of a locale ID 0268 * (including the terminating NULL). 0269 * @stable ICU 2.8 0270 */ 0271 #define ULOC_SCRIPT_CAPACITY 6 0272 0273 /** 0274 * Useful constant for the maximum size of keywords in a locale 0275 * @stable ICU 2.8 0276 */ 0277 #define ULOC_KEYWORDS_CAPACITY 96 0278 0279 /** 0280 * Useful constant for the maximum total size of keywords and their values in a locale 0281 * @stable ICU 2.8 0282 */ 0283 #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100 0284 0285 /** 0286 * Invariant character separating keywords from the locale string 0287 * @stable ICU 2.8 0288 */ 0289 #define ULOC_KEYWORD_SEPARATOR '@' 0290 0291 /** 0292 * Unicode code point for '@' separating keywords from the locale string. 0293 * @see ULOC_KEYWORD_SEPARATOR 0294 * @stable ICU 4.6 0295 */ 0296 #define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40 0297 0298 /** 0299 * Invariant character for assigning value to a keyword 0300 * @stable ICU 2.8 0301 */ 0302 #define ULOC_KEYWORD_ASSIGN '=' 0303 0304 /** 0305 * Unicode code point for '=' for assigning value to a keyword. 0306 * @see ULOC_KEYWORD_ASSIGN 0307 * @stable ICU 4.6 0308 */ 0309 #define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D 0310 0311 /** 0312 * Invariant character separating keywords 0313 * @stable ICU 2.8 0314 */ 0315 #define ULOC_KEYWORD_ITEM_SEPARATOR ';' 0316 0317 /** 0318 * Unicode code point for ';' separating keywords 0319 * @see ULOC_KEYWORD_ITEM_SEPARATOR 0320 * @stable ICU 4.6 0321 */ 0322 #define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B 0323 0324 /** 0325 * Constants for *_getLocale() 0326 * Allow user to select whether she wants information on 0327 * requested, valid or actual locale. 0328 * For example, a collator for "en_US_CALIFORNIA" was 0329 * requested. In the current state of ICU (2.0), 0330 * the requested locale is "en_US_CALIFORNIA", 0331 * the valid locale is "en_US" (most specific locale supported by ICU) 0332 * and the actual locale is "root" (the collation data comes unmodified 0333 * from the UCA) 0334 * The locale is considered supported by ICU if there is a core ICU bundle 0335 * for that locale (although it may be empty). 0336 * @stable ICU 2.1 0337 */ 0338 typedef enum { 0339 /** This is locale the data actually comes from 0340 * @stable ICU 2.1 0341 */ 0342 ULOC_ACTUAL_LOCALE = 0, 0343 /** This is the most specific locale supported by ICU 0344 * @stable ICU 2.1 0345 */ 0346 ULOC_VALID_LOCALE = 1, 0347 0348 #ifndef U_HIDE_DEPRECATED_API 0349 /** This is the requested locale 0350 * @deprecated ICU 2.8 0351 */ 0352 ULOC_REQUESTED_LOCALE = 2, 0353 0354 /** 0355 * One more than the highest normal ULocDataLocaleType value. 0356 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 0357 */ 0358 ULOC_DATA_LOCALE_TYPE_LIMIT = 3 0359 #endif // U_HIDE_DEPRECATED_API 0360 } ULocDataLocaleType; 0361 0362 #ifndef U_HIDE_SYSTEM_API 0363 /** 0364 * Gets ICU's default locale. 0365 * The returned string is a snapshot in time, and will remain valid 0366 * and unchanged even when uloc_setDefault() is called. 0367 * The returned storage is owned by ICU, and must not be altered or deleted 0368 * by the caller. 0369 * 0370 * @return the ICU default locale 0371 * @system 0372 * @stable ICU 2.0 0373 */ 0374 U_CAPI const char* U_EXPORT2 0375 uloc_getDefault(void); 0376 0377 /** 0378 * Sets ICU's default locale. 0379 * By default (without calling this function), ICU's default locale will be based 0380 * on information obtained from the underlying system environment. 0381 * <p> 0382 * Changes to ICU's default locale do not propagate back to the 0383 * system environment. 0384 * <p> 0385 * Changes to ICU's default locale to not affect any ICU services that 0386 * may already be open based on the previous default locale value. 0387 * 0388 * @param localeID the new ICU default locale. A value of NULL will try to get 0389 * the system's default locale. 0390 * @param status the error information if the setting of default locale fails 0391 * @system 0392 * @stable ICU 2.0 0393 */ 0394 U_CAPI void U_EXPORT2 0395 uloc_setDefault(const char* localeID, 0396 UErrorCode* status); 0397 #endif /* U_HIDE_SYSTEM_API */ 0398 0399 /** 0400 * Gets the language code for the specified locale. 0401 * 0402 * @param localeID the locale to get the ISO language code with 0403 * @param language the language code for localeID 0404 * @param languageCapacity the size of the language buffer to store the 0405 * language code with 0406 * @param err error information if retrieving the language code failed 0407 * @return the actual buffer size needed for the language code. If it's greater 0408 * than languageCapacity, the returned language code will be truncated. 0409 * @stable ICU 2.0 0410 */ 0411 U_CAPI int32_t U_EXPORT2 0412 uloc_getLanguage(const char* localeID, 0413 char* language, 0414 int32_t languageCapacity, 0415 UErrorCode* err); 0416 0417 /** 0418 * Gets the script code for the specified locale. 0419 * 0420 * @param localeID the locale to get the ISO language code with 0421 * @param script the language code for localeID 0422 * @param scriptCapacity the size of the language buffer to store the 0423 * language code with 0424 * @param err error information if retrieving the language code failed 0425 * @return the actual buffer size needed for the language code. If it's greater 0426 * than scriptCapacity, the returned language code will be truncated. 0427 * @stable ICU 2.8 0428 */ 0429 U_CAPI int32_t U_EXPORT2 0430 uloc_getScript(const char* localeID, 0431 char* script, 0432 int32_t scriptCapacity, 0433 UErrorCode* err); 0434 0435 /** 0436 * Gets the country code for the specified locale. 0437 * 0438 * @param localeID the locale to get the country code with 0439 * @param country the country code for localeID 0440 * @param countryCapacity the size of the country buffer to store the 0441 * country code with 0442 * @param err error information if retrieving the country code failed 0443 * @return the actual buffer size needed for the country code. If it's greater 0444 * than countryCapacity, the returned country code will be truncated. 0445 * @stable ICU 2.0 0446 */ 0447 U_CAPI int32_t U_EXPORT2 0448 uloc_getCountry(const char* localeID, 0449 char* country, 0450 int32_t countryCapacity, 0451 UErrorCode* err); 0452 0453 /** 0454 * Gets the variant code for the specified locale. 0455 * 0456 * @param localeID the locale to get the variant code with 0457 * @param variant the variant code for localeID 0458 * @param variantCapacity the size of the variant buffer to store the 0459 * variant code with 0460 * @param err error information if retrieving the variant code failed 0461 * @return the actual buffer size needed for the variant code. If it's greater 0462 * than variantCapacity, the returned variant code will be truncated. 0463 * @stable ICU 2.0 0464 */ 0465 U_CAPI int32_t U_EXPORT2 0466 uloc_getVariant(const char* localeID, 0467 char* variant, 0468 int32_t variantCapacity, 0469 UErrorCode* err); 0470 0471 0472 /** 0473 * Gets the full name for the specified locale. 0474 * Note: This has the effect of 'canonicalizing' the ICU locale ID to 0475 * a certain extent. Upper and lower case are set as needed. 0476 * It does NOT map aliased names in any way. 0477 * See the top of this header file. 0478 * This API supports preflighting. 0479 * 0480 * @param localeID the locale to get the full name with 0481 * @param name fill in buffer for the name without keywords. 0482 * @param nameCapacity capacity of the fill in buffer. 0483 * @param err error information if retrieving the full name failed 0484 * @return the actual buffer size needed for the full name. If it's greater 0485 * than nameCapacity, the returned full name will be truncated. 0486 * @stable ICU 2.0 0487 */ 0488 U_CAPI int32_t U_EXPORT2 0489 uloc_getName(const char* localeID, 0490 char* name, 0491 int32_t nameCapacity, 0492 UErrorCode* err); 0493 0494 /** 0495 * Gets the full name for the specified locale. 0496 * Note: This has the effect of 'canonicalizing' the string to 0497 * a certain extent. Upper and lower case are set as needed, 0498 * and if the components were in 'POSIX' format they are changed to 0499 * ICU format. It does NOT map aliased names in any way. 0500 * See the top of this header file. 0501 * 0502 * @param localeID the locale to get the full name with 0503 * @param name the full name for localeID 0504 * @param nameCapacity the size of the name buffer to store the 0505 * full name with 0506 * @param err error information if retrieving the full name failed 0507 * @return the actual buffer size needed for the full name. If it's greater 0508 * than nameCapacity, the returned full name will be truncated. 0509 * @stable ICU 2.8 0510 */ 0511 U_CAPI int32_t U_EXPORT2 0512 uloc_canonicalize(const char* localeID, 0513 char* name, 0514 int32_t nameCapacity, 0515 UErrorCode* err); 0516 0517 /** 0518 * Gets the ISO language code for the specified locale. 0519 * 0520 * @param localeID the locale to get the ISO language code with 0521 * @return language the ISO language code for localeID 0522 * @stable ICU 2.0 0523 */ 0524 U_CAPI const char* U_EXPORT2 0525 uloc_getISO3Language(const char* localeID); 0526 0527 0528 /** 0529 * Gets the ISO country code for the specified locale. 0530 * 0531 * @param localeID the locale to get the ISO country code with 0532 * @return country the ISO country code for localeID 0533 * @stable ICU 2.0 0534 */ 0535 U_CAPI const char* U_EXPORT2 0536 uloc_getISO3Country(const char* localeID); 0537 0538 /** 0539 * Gets the Win32 LCID value for the specified locale. 0540 * If the ICU locale is not recognized by Windows, 0 will be returned. 0541 * 0542 * LCIDs were deprecated with Windows Vista and Microsoft recommends 0543 * that developers use BCP47 style tags instead (uloc_toLanguageTag). 0544 * 0545 * @param localeID the locale to get the Win32 LCID value with 0546 * @return country the Win32 LCID for localeID 0547 * @stable ICU 2.0 0548 */ 0549 U_CAPI uint32_t U_EXPORT2 0550 uloc_getLCID(const char* localeID); 0551 0552 /** 0553 * Gets the language name suitable for display for the specified locale. 0554 * 0555 * @param locale the locale to get the ISO language code with 0556 * @param displayLocale Specifies the locale to be used to display the name. In 0557 * other words, if the locale's language code is "en", passing 0558 * Locale::getFrench() for inLocale would result in "Anglais", 0559 * while passing Locale::getGerman() for inLocale would result 0560 * in "Englisch". 0561 * @param language the displayable language code for localeID 0562 * @param languageCapacity the size of the language buffer to store the 0563 * displayable language code with. 0564 * @param status error information if retrieving the displayable language code 0565 * failed. U_USING_DEFAULT_WARNING indicates that no data was 0566 * found from the locale resources and a case canonicalized 0567 * language code is placed into language as fallback. 0568 * @return the actual buffer size needed for the displayable language code. If 0569 * it's greater than languageCapacity, the returned language 0570 * code will be truncated. 0571 * @stable ICU 2.0 0572 */ 0573 U_CAPI int32_t U_EXPORT2 0574 uloc_getDisplayLanguage(const char* locale, 0575 const char* displayLocale, 0576 UChar* language, 0577 int32_t languageCapacity, 0578 UErrorCode* status); 0579 0580 /** 0581 * Gets the script name suitable for display for the specified locale. 0582 * 0583 * @param locale the locale to get the displayable script code with. NULL may be 0584 * used to specify the default. 0585 * @param displayLocale Specifies the locale to be used to display the name. In 0586 * other words, if the locale's language code is "en", passing 0587 * Locale::getFrench() for inLocale would result in "", while 0588 * passing Locale::getGerman() for inLocale would result in "". 0589 * NULL may be used to specify the default. 0590 * @param script the displayable script for the localeID. 0591 * @param scriptCapacity the size of the script buffer to store the displayable 0592 * script code with. 0593 * @param status error information if retrieving the displayable script code 0594 * failed. U_USING_DEFAULT_WARNING indicates that no data was 0595 * found from the locale resources and a case canonicalized 0596 * script code is placed into script as fallback. 0597 * @return the actual buffer size needed for the displayable script code. If 0598 * it's greater than scriptCapacity, the returned displayable 0599 * script code will be truncated. 0600 * @stable ICU 2.8 0601 */ 0602 U_CAPI int32_t U_EXPORT2 0603 uloc_getDisplayScript(const char* locale, 0604 const char* displayLocale, 0605 UChar* script, 0606 int32_t scriptCapacity, 0607 UErrorCode* status); 0608 0609 /** 0610 * Gets the country name suitable for display for the specified locale. 0611 * Warning: this is for the region part of a valid locale ID; it cannot just be 0612 * the region code (like "FR"). To get the display name for a region alone, or 0613 * for other options, use ULocaleDisplayNames instead. 0614 * 0615 * @param locale the locale to get the displayable country code with. NULL may 0616 * be used to specify the default. 0617 * @param displayLocale Specifies the locale to be used to display the name. In 0618 * other words, if the locale's language code is "en", passing 0619 * Locale::getFrench() for inLocale would result in "Anglais", 0620 * while passing Locale::getGerman() for inLocale would result 0621 * in "Englisch". NULL may be used to specify the default. 0622 * @param country the displayable country code for localeID. 0623 * @param countryCapacity the size of the country buffer to store the 0624 * displayable country code with. 0625 * @param status error information if retrieving the displayable country code 0626 * failed. U_USING_DEFAULT_WARNING indicates that no data was 0627 * found from the locale resources and a case canonicalized 0628 * country code is placed into country as fallback. 0629 * @return the actual buffer size needed for the displayable country code. If 0630 * it's greater than countryCapacity, the returned displayable 0631 * country code will be truncated. 0632 * @stable ICU 2.0 0633 */ 0634 U_CAPI int32_t U_EXPORT2 0635 uloc_getDisplayCountry(const char* locale, 0636 const char* displayLocale, 0637 UChar* country, 0638 int32_t countryCapacity, 0639 UErrorCode* status); 0640 0641 0642 /** 0643 * Gets the variant name suitable for display for the specified locale. 0644 * 0645 * @param locale the locale to get the displayable variant code with. NULL may 0646 * be used to specify the default. 0647 * @param displayLocale Specifies the locale to be used to display the name. In 0648 * other words, if the locale's language code is "en", passing 0649 * Locale::getFrench() for inLocale would result in "Anglais", 0650 * while passing Locale::getGerman() for inLocale would result 0651 * in "Englisch". NULL may be used to specify the default. 0652 * @param variant the displayable variant code for localeID. 0653 * @param variantCapacity the size of the variant buffer to store the 0654 * displayable variant code with. 0655 * @param status error information if retrieving the displayable variant code 0656 * failed. U_USING_DEFAULT_WARNING indicates that no data was 0657 * found from the locale resources and a case canonicalized 0658 * variant code is placed into variant as fallback. 0659 * @return the actual buffer size needed for the displayable variant code. If 0660 * it's greater than variantCapacity, the returned displayable 0661 * variant code will be truncated. 0662 * @stable ICU 2.0 0663 */ 0664 U_CAPI int32_t U_EXPORT2 0665 uloc_getDisplayVariant(const char* locale, 0666 const char* displayLocale, 0667 UChar* variant, 0668 int32_t variantCapacity, 0669 UErrorCode* status); 0670 0671 /** 0672 * Gets the keyword name suitable for display for the specified locale. E.g: 0673 * for the locale string de_DE\@collation=PHONEBOOK, this API gets the display 0674 * string for the keyword collation. 0675 * Usage: 0676 * <code> 0677 * UErrorCode status = U_ZERO_ERROR; 0678 * const char* keyword =NULL; 0679 * int32_t keywordLen = 0; 0680 * int32_t keywordCount = 0; 0681 * UChar displayKeyword[256]; 0682 * int32_t displayKeywordLen = 0; 0683 * UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status); 0684 * for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){ 0685 * if(U_FAILURE(status)){ 0686 * ...something went wrong so handle the error... 0687 * break; 0688 * } 0689 * // the uenum_next returns NUL terminated string 0690 * keyword = uenum_next(keywordEnum, &keywordLen, &status); 0691 * displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256); 0692 * ... do something interesting ..... 0693 * } 0694 * uenum_close(keywordEnum); 0695 * </code> 0696 * @param keyword The keyword whose display string needs to be returned. 0697 * @param displayLocale Specifies the locale to be used to display the name. In other words, 0698 * if the locale's language code is "en", passing Locale::getFrench() for 0699 * inLocale would result in "Anglais", while passing Locale::getGerman() 0700 * for inLocale would result in "Englisch". NULL may be used to specify the default. 0701 * @param dest the buffer to which the displayable keyword should be written. 0702 * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 0703 * dest may be NULL and the function will only return the length of the 0704 * result without writing any of the result string (pre-flighting). 0705 * @param status error information if retrieving the displayable string failed. 0706 * Should not be NULL and should not indicate failure on entry. 0707 * U_USING_DEFAULT_WARNING indicates that no data was found from the locale 0708 * resources and the keyword is placed into dest as fallback. 0709 * @return the actual buffer size needed for the displayable variant code. 0710 * @see #uloc_openKeywords 0711 * @stable ICU 2.8 0712 */ 0713 U_CAPI int32_t U_EXPORT2 0714 uloc_getDisplayKeyword(const char* keyword, 0715 const char* displayLocale, 0716 UChar* dest, 0717 int32_t destCapacity, 0718 UErrorCode* status); 0719 /** 0720 * Gets the value of the keyword suitable for display for the specified locale. 0721 * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display 0722 * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword. 0723 * 0724 * @param locale The locale to get the displayable variant code with. NULL may be used to specify the default. 0725 * @param keyword The keyword for whose value should be used. 0726 * @param displayLocale Specifies the locale to be used to display the name. In other words, 0727 * if the locale's language code is "en", passing Locale::getFrench() for 0728 * inLocale would result in "Anglais", while passing Locale::getGerman() 0729 * for inLocale would result in "Englisch". NULL may be used to specify the default. 0730 * @param dest the buffer to which the displayable keyword should be written. 0731 * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 0732 * dest may be NULL and the function will only return the length of the 0733 * result without writing any of the result string (pre-flighting). 0734 * @param status error information if retrieving the displayable string failed. 0735 * Should not be NULL and must not indicate failure on entry. 0736 * U_USING_DEFAULT_WARNING indicates that no data was found from the locale 0737 * resources and the value of the keyword is placed into dest as fallback. 0738 * @return the actual buffer size needed for the displayable variant code. 0739 * @stable ICU 2.8 0740 */ 0741 U_CAPI int32_t U_EXPORT2 0742 uloc_getDisplayKeywordValue( const char* locale, 0743 const char* keyword, 0744 const char* displayLocale, 0745 UChar* dest, 0746 int32_t destCapacity, 0747 UErrorCode* status); 0748 /** 0749 * Gets the full name suitable for display for the specified locale. 0750 * 0751 * @param localeID the locale to get the displayable name with. NULL may be used to specify the default. 0752 * @param inLocaleID Specifies the locale to be used to display the name. In other words, 0753 * if the locale's language code is "en", passing Locale::getFrench() for 0754 * inLocale would result in "Anglais", while passing Locale::getGerman() 0755 * for inLocale would result in "Englisch". NULL may be used to specify the default. 0756 * @param result the displayable name for localeID 0757 * @param maxResultSize the size of the name buffer to store the 0758 * displayable full name with 0759 * @param err error information if retrieving the displayable name failed 0760 * @return the actual buffer size needed for the displayable name. If it's greater 0761 * than maxResultSize, the returned displayable name will be truncated. 0762 * @stable ICU 2.0 0763 */ 0764 U_CAPI int32_t U_EXPORT2 0765 uloc_getDisplayName(const char* localeID, 0766 const char* inLocaleID, 0767 UChar* result, 0768 int32_t maxResultSize, 0769 UErrorCode* err); 0770 0771 0772 /** 0773 * Gets the specified locale from a list of available locales. 0774 * 0775 * This method corresponds to uloc_openAvailableByType called with the 0776 * ULOC_AVAILABLE_DEFAULT type argument. 0777 * 0778 * The return value is a pointer to an item of a locale name array. Both this 0779 * array and the pointers it contains are owned by ICU and should not be 0780 * deleted or written through by the caller. The locale name is terminated by 0781 * a null pointer. 0782 * 0783 * @param n the specific locale name index of the available locale list; 0784 * should not exceed the number returned by uloc_countAvailable. 0785 * @return a specified locale name of all available locales 0786 * @stable ICU 2.0 0787 */ 0788 U_CAPI const char* U_EXPORT2 0789 uloc_getAvailable(int32_t n); 0790 0791 /** 0792 * Gets the size of the all available locale list. 0793 * 0794 * @return the size of the locale list 0795 * @stable ICU 2.0 0796 */ 0797 U_CAPI int32_t U_EXPORT2 uloc_countAvailable(void); 0798 0799 /** 0800 * Types for uloc_getAvailableByType and uloc_countAvailableByType. 0801 * 0802 * @stable ICU 65 0803 */ 0804 typedef enum ULocAvailableType { 0805 /** 0806 * Locales that return data when passed to ICU APIs, 0807 * but not including legacy or alias locales. 0808 * 0809 * @stable ICU 65 0810 */ 0811 ULOC_AVAILABLE_DEFAULT, 0812 0813 /** 0814 * Legacy or alias locales that return data when passed to ICU APIs. 0815 * Examples of supported legacy or alias locales: 0816 * 0817 * - iw (alias to he) 0818 * - mo (alias to ro) 0819 * - zh_CN (alias to zh_Hans_CN) 0820 * - sr_BA (alias to sr_Cyrl_BA) 0821 * - ars (alias to ar_SA) 0822 * 0823 * The locales in this set are disjoint from the ones in 0824 * ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use 0825 * ULOC_AVAILABLE_WITH_LEGACY_ALIASES. 0826 * 0827 * @stable ICU 65 0828 */ 0829 ULOC_AVAILABLE_ONLY_LEGACY_ALIASES, 0830 0831 /** 0832 * The union of the locales in ULOC_AVAILABLE_DEFAULT and 0833 * ULOC_AVAILABLE_ONLY_LEGACY_ALIAS. 0834 * 0835 * @stable ICU 65 0836 */ 0837 ULOC_AVAILABLE_WITH_LEGACY_ALIASES, 0838 0839 #ifndef U_HIDE_INTERNAL_API 0840 /** 0841 * @internal 0842 */ 0843 ULOC_AVAILABLE_COUNT 0844 #endif /* U_HIDE_INTERNAL_API */ 0845 } ULocAvailableType; 0846 0847 /** 0848 * Gets a list of available locales according to the type argument, allowing 0849 * the user to access different sets of supported locales in ICU. 0850 * 0851 * The returned UEnumeration must be closed by the caller. 0852 * 0853 * @param type Type choice from ULocAvailableType. 0854 * @param status Set if an error occurred. 0855 * @return a UEnumeration owned by the caller, or nullptr on failure. 0856 * @stable ICU 65 0857 */ 0858 U_CAPI UEnumeration* U_EXPORT2 0859 uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status); 0860 0861 /** 0862 * 0863 * Gets a list of all available 2-letter language codes defined in ISO 639, 0864 * plus additional 3-letter codes determined to be useful for locale generation as 0865 * defined by Unicode CLDR. This is a pointer 0866 * to an array of pointers to arrays of char. All of these pointers are owned 0867 * by ICU-- do not delete them, and do not write through them. The array is 0868 * terminated with a null pointer. 0869 * @return a list of all available language codes 0870 * @stable ICU 2.0 0871 */ 0872 U_CAPI const char* const* U_EXPORT2 0873 uloc_getISOLanguages(void); 0874 0875 /** 0876 * 0877 * Gets a list of all available 2-letter country codes defined in ISO 639. This is a 0878 * pointer to an array of pointers to arrays of char. All of these pointers are 0879 * owned by ICU-- do not delete them, and do not write through them. The array is 0880 * terminated with a null pointer. 0881 * @return a list of all available country codes 0882 * @stable ICU 2.0 0883 */ 0884 U_CAPI const char* const* U_EXPORT2 0885 uloc_getISOCountries(void); 0886 0887 /** 0888 * Truncate the locale ID string to get the parent locale ID. 0889 * Copies the part of the string before the last underscore. 0890 * The parent locale ID will be an empty string if there is no 0891 * underscore, or if there is only one underscore at localeID[0]. 0892 * 0893 * @param localeID Input locale ID string. 0894 * @param parent Output string buffer for the parent locale ID. 0895 * @param parentCapacity Size of the output buffer. 0896 * @param err A UErrorCode value. 0897 * @return The length of the parent locale ID. 0898 * @stable ICU 2.0 0899 */ 0900 U_CAPI int32_t U_EXPORT2 0901 uloc_getParent(const char* localeID, 0902 char* parent, 0903 int32_t parentCapacity, 0904 UErrorCode* err); 0905 0906 0907 0908 0909 /** 0910 * Gets the full name for the specified locale, like uloc_getName(), 0911 * but without keywords. 0912 * 0913 * Note: This has the effect of 'canonicalizing' the string to 0914 * a certain extent. Upper and lower case are set as needed, 0915 * and if the components were in 'POSIX' format they are changed to 0916 * ICU format. It does NOT map aliased names in any way. 0917 * See the top of this header file. 0918 * 0919 * This API strips off the keyword part, so "de_DE\@collation=phonebook" 0920 * will become "de_DE". 0921 * This API supports preflighting. 0922 * 0923 * @param localeID the locale to get the full name with 0924 * @param name fill in buffer for the name without keywords. 0925 * @param nameCapacity capacity of the fill in buffer. 0926 * @param err error information if retrieving the full name failed 0927 * @return the actual buffer size needed for the full name. If it's greater 0928 * than nameCapacity, the returned full name will be truncated. 0929 * @stable ICU 2.8 0930 */ 0931 U_CAPI int32_t U_EXPORT2 0932 uloc_getBaseName(const char* localeID, 0933 char* name, 0934 int32_t nameCapacity, 0935 UErrorCode* err); 0936 0937 /** 0938 * Gets an enumeration of keywords for the specified locale. Enumeration 0939 * must get disposed of by the client using uenum_close function. 0940 * 0941 * @param localeID the locale to get the variant code with 0942 * @param status error information if retrieving the keywords failed 0943 * @return enumeration of keywords or NULL if there are no keywords. 0944 * @stable ICU 2.8 0945 */ 0946 U_CAPI UEnumeration* U_EXPORT2 0947 uloc_openKeywords(const char* localeID, 0948 UErrorCode* status); 0949 0950 /** 0951 * Get the value for a keyword. Locale name does not need to be normalized. 0952 * 0953 * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK") 0954 * @param keywordName name of the keyword for which we want the value; must not be 0955 * NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive. 0956 * @param buffer receiving buffer 0957 * @param bufferCapacity capacity of receiving buffer 0958 * @param status containing error code: e.g. buffer not big enough or ill-formed localeID 0959 * or keywordName parameters. 0960 * @return the length of keyword value 0961 * @stable ICU 2.8 0962 */ 0963 U_CAPI int32_t U_EXPORT2 0964 uloc_getKeywordValue(const char* localeID, 0965 const char* keywordName, 0966 char* buffer, int32_t bufferCapacity, 0967 UErrorCode* status); 0968 0969 0970 /** 0971 * Sets or removes the value of the specified keyword. 0972 * 0973 * For removing all keywords, use uloc_getBaseName(). 0974 * 0975 * NOTE: Unlike almost every other ICU function which takes a 0976 * buffer, this function will NOT truncate the output text, and will 0977 * not update the buffer with unterminated text setting a status of 0978 * U_STRING_NOT_TERMINATED_WARNING. If a BUFFER_OVERFLOW_ERROR is received, 0979 * it means a terminated version of the updated locale ID would not fit 0980 * in the buffer, and the original buffer is untouched. This is done to 0981 * prevent incorrect or possibly even malformed locales from being generated 0982 * and used. 0983 * 0984 * @param keywordName name of the keyword to be set; must not be 0985 * NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive. 0986 * @param keywordValue value of the keyword to be set. If 0-length or 0987 * NULL, will result in the keyword being removed; no error is given if 0988 * that keyword does not exist. Otherwise, must consist only of 0989 * [A-Za-z0-9] and [/_+-]. 0990 * @param buffer input buffer containing well-formed locale ID to be 0991 * modified. 0992 * @param bufferCapacity capacity of receiving buffer 0993 * @param status containing error code: e.g. buffer not big enough 0994 * or ill-formed keywordName or keywordValue parameters, or ill-formed 0995 * locale ID in buffer on input. 0996 * @return the length needed for the buffer 0997 * @see uloc_getKeywordValue 0998 * @stable ICU 3.2 0999 */ 1000 U_CAPI int32_t U_EXPORT2 1001 uloc_setKeywordValue(const char* keywordName, 1002 const char* keywordValue, 1003 char* buffer, int32_t bufferCapacity, 1004 UErrorCode* status); 1005 1006 /** 1007 * Returns whether the locale's script is written right-to-left. 1008 * If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags(). 1009 * If no likely script is known, then false is returned. 1010 * 1011 * A script is right-to-left according to the CLDR script metadata 1012 * which corresponds to whether the script's letters have Bidi_Class=R or AL. 1013 * 1014 * Returns true for "ar" and "en-Hebr", false for "zh" and "fa-Cyrl". 1015 * 1016 * @param locale input locale ID 1017 * @return true if the locale's script is written right-to-left 1018 * @stable ICU 54 1019 */ 1020 U_CAPI UBool U_EXPORT2 1021 uloc_isRightToLeft(const char *locale); 1022 1023 /** 1024 * enums for the return value for the character and line orientation 1025 * functions. 1026 * @stable ICU 4.0 1027 */ 1028 typedef enum { 1029 ULOC_LAYOUT_LTR = 0, /* left-to-right. */ 1030 ULOC_LAYOUT_RTL = 1, /* right-to-left. */ 1031 ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */ 1032 ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */ 1033 ULOC_LAYOUT_UNKNOWN 1034 } ULayoutType; 1035 1036 /** 1037 * Get the layout character orientation for the specified locale. 1038 * 1039 * @param localeId locale name 1040 * @param status Error status 1041 * @return an enum indicating the layout orientation for characters. 1042 * @stable ICU 4.0 1043 */ 1044 U_CAPI ULayoutType U_EXPORT2 1045 uloc_getCharacterOrientation(const char* localeId, 1046 UErrorCode *status); 1047 1048 /** 1049 * Get the layout line orientation for the specified locale. 1050 * 1051 * @param localeId locale name 1052 * @param status Error status 1053 * @return an enum indicating the layout orientation for lines. 1054 * @stable ICU 4.0 1055 */ 1056 U_CAPI ULayoutType U_EXPORT2 1057 uloc_getLineOrientation(const char* localeId, 1058 UErrorCode *status); 1059 1060 /** 1061 * Output values which uloc_acceptLanguage() writes to the 'outResult' parameter. 1062 * 1063 * @see uloc_acceptLanguageFromHTTP 1064 * @see uloc_acceptLanguage 1065 * @stable ICU 3.2 1066 */ 1067 typedef enum { 1068 /** 1069 * No exact match was found. 1070 * @stable ICU 3.2 1071 */ 1072 ULOC_ACCEPT_FAILED = 0, 1073 /** 1074 * An exact match was found. 1075 * @stable ICU 3.2 1076 */ 1077 ULOC_ACCEPT_VALID = 1, 1078 /** 1079 * A fallback was found. For example, the Accept-Language list includes 'ja_JP' 1080 * and is matched with available locale 'ja'. 1081 * @stable ICU 3.2 1082 */ 1083 ULOC_ACCEPT_FALLBACK = 2 /* */ 1084 } UAcceptResult; 1085 1086 /** 1087 * Based on a HTTP header from a web browser and a list of available locales, 1088 * determine an acceptable locale for the user. 1089 * 1090 * This is a thin wrapper over C++ class LocaleMatcher. 1091 * 1092 * @param result - buffer to accept the result locale 1093 * @param resultAvailable the size of the result buffer. 1094 * @param outResult - An out parameter that contains the fallback status 1095 * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP. 1096 * @param availableLocales - list of available locales to match 1097 * @param status ICU error code. Its input value must pass the U_SUCCESS() test, 1098 * or else the function returns immediately. Check for U_FAILURE() 1099 * on output or use with function chaining. (See User Guide for details.) 1100 * @return length needed for the locale. 1101 * @stable ICU 3.2 1102 */ 1103 U_CAPI int32_t U_EXPORT2 1104 uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, 1105 UAcceptResult *outResult, 1106 const char *httpAcceptLanguage, 1107 UEnumeration* availableLocales, 1108 UErrorCode *status); 1109 1110 /** 1111 * Based on a list of available locales, 1112 * determine an acceptable locale for the user. 1113 * 1114 * This is a thin wrapper over C++ class LocaleMatcher. 1115 * 1116 * @param result - buffer to accept the result locale 1117 * @param resultAvailable the size of the result buffer. 1118 * @param outResult - An out parameter that contains the fallback status 1119 * @param acceptList - list of acceptable languages 1120 * @param acceptListCount - count of acceptList items 1121 * @param availableLocales - list of available locales to match 1122 * @param status ICU error code. Its input value must pass the U_SUCCESS() test, 1123 * or else the function returns immediately. Check for U_FAILURE() 1124 * on output or use with function chaining. (See User Guide for details.) 1125 * @return length needed for the locale. 1126 * @stable ICU 3.2 1127 */ 1128 U_CAPI int32_t U_EXPORT2 1129 uloc_acceptLanguage(char *result, int32_t resultAvailable, 1130 UAcceptResult *outResult, const char **acceptList, 1131 int32_t acceptListCount, 1132 UEnumeration* availableLocales, 1133 UErrorCode *status); 1134 1135 1136 /** 1137 * Gets the ICU locale ID for the specified Win32 LCID value. 1138 * 1139 * @param hostID the Win32 LCID to translate 1140 * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated 1141 * if there is room. 1142 * @param localeCapacity the size of the output buffer 1143 * @param status an error is returned if the LCID is unrecognized or the output buffer 1144 * is too small 1145 * @return actual the actual size of the locale ID, not including NUL-termination 1146 * @stable ICU 3.8 1147 */ 1148 U_CAPI int32_t U_EXPORT2 1149 uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity, 1150 UErrorCode *status); 1151 1152 1153 /** 1154 * Add the likely subtags for a provided locale ID, per the algorithm described 1155 * in the following CLDR technical report: 1156 * 1157 * http://www.unicode.org/reports/tr35/#Likely_Subtags 1158 * 1159 * If localeID is already in the maximal form, or there is no data available 1160 * for maximization, it will be copied to the output buffer. For example, 1161 * "und-Zzzz" cannot be maximized, since there is no reasonable maximization. 1162 * 1163 * Examples: 1164 * 1165 * "en" maximizes to "en_Latn_US" 1166 * 1167 * "de" maximizes to "de_Latn_US" 1168 * 1169 * "sr" maximizes to "sr_Cyrl_RS" 1170 * 1171 * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) 1172 * 1173 * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.) 1174 * 1175 * @param localeID The locale to maximize 1176 * @param maximizedLocaleID The maximized locale 1177 * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer 1178 * @param err Error information if maximizing the locale failed. If the length 1179 * of the localeID and the null-terminator is greater than the maximum allowed size, 1180 * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR. 1181 * @return The actual buffer size needed for the maximized locale. If it's 1182 * greater than maximizedLocaleIDCapacity, the returned ID will be truncated. 1183 * On error, the return value is -1. 1184 * @stable ICU 4.0 1185 */ 1186 U_CAPI int32_t U_EXPORT2 1187 uloc_addLikelySubtags(const char* localeID, 1188 char* maximizedLocaleID, 1189 int32_t maximizedLocaleIDCapacity, 1190 UErrorCode* err); 1191 1192 1193 /** 1194 * Minimize the subtags for a provided locale ID, per the algorithm described 1195 * in the following CLDR technical report: 1196 * 1197 * http://www.unicode.org/reports/tr35/#Likely_Subtags 1198 * 1199 * If localeID is already in the minimal form, or there is no data available 1200 * for minimization, it will be copied to the output buffer. Since the 1201 * minimization algorithm relies on proper maximization, see the comments 1202 * for uloc_addLikelySubtags for reasons why there might not be any data. 1203 * 1204 * Examples: 1205 * 1206 * "en_Latn_US" minimizes to "en" 1207 * 1208 * "de_Latn_US" minimizes to "de" 1209 * 1210 * "sr_Cyrl_RS" minimizes to "sr" 1211 * 1212 * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the 1213 * script, and minimizing to "zh" would imply "zh_Hans_CN".) 1214 * 1215 * @param localeID The locale to minimize 1216 * @param minimizedLocaleID The minimized locale 1217 * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer 1218 * @param err Error information if minimizing the locale failed. If the length 1219 * of the localeID and the null-terminator is greater than the maximum allowed size, 1220 * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR. 1221 * @return The actual buffer size needed for the minimized locale. If it's 1222 * greater than minimizedLocaleIDCapacity, the returned ID will be truncated. 1223 * On error, the return value is -1. 1224 * @stable ICU 4.0 1225 */ 1226 U_CAPI int32_t U_EXPORT2 1227 uloc_minimizeSubtags(const char* localeID, 1228 char* minimizedLocaleID, 1229 int32_t minimizedLocaleIDCapacity, 1230 UErrorCode* err); 1231 1232 /** 1233 * Returns a locale ID for the specified BCP47 language tag string. 1234 * If the specified language tag contains any ill-formed subtags, 1235 * the first such subtag and all following subtags are ignored. 1236 * <p> 1237 * This implements the 'Language-Tag' production of BCP 47, and so 1238 * supports legacy language tags (marked as “Type: grandfathered” in BCP 47) 1239 * (regular and irregular) as well as private use language tags. 1240 * 1241 * Private use tags are represented as 'x-whatever', 1242 * and legacy tags are converted to their canonical replacements where they exist. 1243 * 1244 * Note that a few legacy tags have no modern replacement; 1245 * these will be converted using the fallback described in 1246 * the first paragraph, so some information might be lost. 1247 * 1248 * @param langtag the input BCP47 language tag. 1249 * @param localeID the output buffer receiving a locale ID for the 1250 * specified BCP47 language tag. 1251 * @param localeIDCapacity the size of the locale ID output buffer. 1252 * @param parsedLength if not NULL, successfully parsed length 1253 * for the input language tag is set. 1254 * @param err error information if receiving the locald ID 1255 * failed. 1256 * @return the length of the locale ID. 1257 * @stable ICU 4.2 1258 */ 1259 U_CAPI int32_t U_EXPORT2 1260 uloc_forLanguageTag(const char* langtag, 1261 char* localeID, 1262 int32_t localeIDCapacity, 1263 int32_t* parsedLength, 1264 UErrorCode* err); 1265 1266 /** 1267 * Returns a well-formed language tag for this locale ID. 1268 * <p> 1269 * <b>Note</b>: When <code>strict</code> is false, any locale 1270 * fields which do not satisfy the BCP47 syntax requirement will 1271 * be omitted from the result. When <code>strict</code> is 1272 * true, this function sets U_ILLEGAL_ARGUMENT_ERROR to the 1273 * <code>err</code> if any locale fields do not satisfy the 1274 * BCP47 syntax requirement. 1275 * @param localeID the input locale ID 1276 * @param langtag the output buffer receiving BCP47 language 1277 * tag for the locale ID. 1278 * @param langtagCapacity the size of the BCP47 language tag 1279 * output buffer. 1280 * @param strict boolean value indicating if the function returns 1281 * an error for an ill-formed input locale ID. 1282 * @param err error information if receiving the language 1283 * tag failed. 1284 * @return The length of the BCP47 language tag. 1285 * @stable ICU 4.2 1286 */ 1287 U_CAPI int32_t U_EXPORT2 1288 uloc_toLanguageTag(const char* localeID, 1289 char* langtag, 1290 int32_t langtagCapacity, 1291 UBool strict, 1292 UErrorCode* err); 1293 1294 /** 1295 * Converts the specified keyword (legacy key, or BCP 47 Unicode locale 1296 * extension key) to the equivalent BCP 47 Unicode locale extension key. 1297 * For example, BCP 47 Unicode locale extension key "co" is returned for 1298 * the input keyword "collation". 1299 * <p> 1300 * When the specified keyword is unknown, but satisfies the BCP syntax, 1301 * then the pointer to the input keyword itself will be returned. 1302 * For example, 1303 * <code>uloc_toUnicodeLocaleKey("ZZ")</code> returns "ZZ". 1304 * 1305 * @param keyword the input locale keyword (either legacy key 1306 * such as "collation" or BCP 47 Unicode locale extension 1307 * key such as "co"). 1308 * @return the well-formed BCP 47 Unicode locale extension key, 1309 * or NULL if the specified locale keyword cannot be 1310 * mapped to a well-formed BCP 47 Unicode locale extension 1311 * key. 1312 * @see uloc_toLegacyKey 1313 * @stable ICU 54 1314 */ 1315 U_CAPI const char* U_EXPORT2 1316 uloc_toUnicodeLocaleKey(const char* keyword); 1317 1318 /** 1319 * Converts the specified keyword value (legacy type, or BCP 47 1320 * Unicode locale extension type) to the well-formed BCP 47 Unicode locale 1321 * extension type for the specified keyword (category). For example, BCP 47 1322 * Unicode locale extension type "phonebk" is returned for the input 1323 * keyword value "phonebook", with the keyword "collation" (or "co"). 1324 * <p> 1325 * When the specified keyword is not recognized, but the specified value 1326 * satisfies the syntax of the BCP 47 Unicode locale extension type, 1327 * or when the specified keyword allows 'variable' type and the specified 1328 * value satisfies the syntax, then the pointer to the input type value itself 1329 * will be returned. 1330 * For example, 1331 * <code>uloc_toUnicodeLocaleType("Foo", "Bar")</code> returns "Bar", 1332 * <code>uloc_toUnicodeLocaleType("variableTop", "00A4")</code> returns "00A4". 1333 * 1334 * @param keyword the locale keyword (either legacy key such as 1335 * "collation" or BCP 47 Unicode locale extension 1336 * key such as "co"). 1337 * @param value the locale keyword value (either legacy type 1338 * such as "phonebook" or BCP 47 Unicode locale extension 1339 * type such as "phonebk"). 1340 * @return the well-formed BCP47 Unicode locale extension type, 1341 * or NULL if the locale keyword value cannot be mapped to 1342 * a well-formed BCP 47 Unicode locale extension type. 1343 * @see uloc_toLegacyType 1344 * @stable ICU 54 1345 */ 1346 U_CAPI const char* U_EXPORT2 1347 uloc_toUnicodeLocaleType(const char* keyword, const char* value); 1348 1349 /** 1350 * Converts the specified keyword (BCP 47 Unicode locale extension key, or 1351 * legacy key) to the legacy key. For example, legacy key "collation" is 1352 * returned for the input BCP 47 Unicode locale extension key "co". 1353 * 1354 * @param keyword the input locale keyword (either BCP 47 Unicode locale 1355 * extension key or legacy key). 1356 * @return the well-formed legacy key, or NULL if the specified 1357 * keyword cannot be mapped to a well-formed legacy key. 1358 * @see toUnicodeLocaleKey 1359 * @stable ICU 54 1360 */ 1361 U_CAPI const char* U_EXPORT2 1362 uloc_toLegacyKey(const char* keyword); 1363 1364 /** 1365 * Converts the specified keyword value (BCP 47 Unicode locale extension type, 1366 * or legacy type or type alias) to the canonical legacy type. For example, 1367 * the legacy type "phonebook" is returned for the input BCP 47 Unicode 1368 * locale extension type "phonebk" with the keyword "collation" (or "co"). 1369 * <p> 1370 * When the specified keyword is not recognized, but the specified value 1371 * satisfies the syntax of legacy key, or when the specified keyword 1372 * allows 'variable' type and the specified value satisfies the syntax, 1373 * then the pointer to the input type value itself will be returned. 1374 * For example, 1375 * <code>uloc_toLegacyType("Foo", "Bar")</code> returns "Bar", 1376 * <code>uloc_toLegacyType("vt", "00A4")</code> returns "00A4". 1377 * 1378 * @param keyword the locale keyword (either legacy keyword such as 1379 * "collation" or BCP 47 Unicode locale extension 1380 * key such as "co"). 1381 * @param value the locale keyword value (either BCP 47 Unicode locale 1382 * extension type such as "phonebk" or legacy keyword value 1383 * such as "phonebook"). 1384 * @return the well-formed legacy type, or NULL if the specified 1385 * keyword value cannot be mapped to a well-formed legacy 1386 * type. 1387 * @see toUnicodeLocaleType 1388 * @stable ICU 54 1389 */ 1390 U_CAPI const char* U_EXPORT2 1391 uloc_toLegacyType(const char* keyword, const char* value); 1392 1393 #endif /*_ULOC*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |