| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 ********************************************************************** | |
| 3 * Copyright (C) 1997-2010, International Business Machines | |
| 4 * Corporation and others. All Rights Reserved. | |
| 5 ********************************************************************** | |
| 6 * | |
| 7 * File ULOC.H | |
| 8 * | |
| 9 * Modification History: | |
| 10 * | |
| 11 * Date Name Description | |
| 12 * 04/01/97 aliu Creation. | |
| 13 * 08/22/98 stephen JDK 1.2 sync. | |
| 14 * 12/08/98 rtg New C API for Locale | |
| 15 * 03/30/99 damiba overhaul | |
| 16 * 03/31/99 helena Javadoc for uloc functions. | |
| 17 * 04/15/99 Madhu Updated Javadoc | |
| 18 ******************************************************************************** | |
| 19 */ | |
| 20 | |
| 21 #ifndef ULOC_H | |
| 22 #define ULOC_H | |
| 23 | |
| 24 #include "unicode/utypes.h" | |
| 25 #include "unicode/uenum.h" | |
| 26 | |
| 27 /** | |
| 28 * \file | |
| 29 * \brief C API: Locale | |
| 30 * | |
| 31 * <h2> ULoc C API for Locale </h2> | |
| 32 * A <code>Locale</code> represents a specific geographical, political, | |
| 33 * or cultural region. An operation that requires a <code>Locale</code> to perfo
rm | |
| 34 * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code> | |
| 35 * to tailor information for the user. For example, displaying a number | |
| 36 * is a locale-sensitive operation--the number should be formatted | |
| 37 * according to the customs/conventions of the user's native country, | |
| 38 * region, or culture. In the C APIs, a locales is simply a const char string. | |
| 39 * | |
| 40 * <P> | |
| 41 * You create a <code>Locale</code> with one of the three options listed below. | |
| 42 * Each of the component is separated by '_' in the locale string. | |
| 43 * \htmlonly<blockquote>\endhtmlonly | |
| 44 * <pre> | |
| 45 * \code | |
| 46 * newLanguage | |
| 47 * | |
| 48 * newLanguage + newCountry | |
| 49 * | |
| 50 * newLanguage + newCountry + newVariant | |
| 51 * \endcode | |
| 52 * </pre> | |
| 53 * \htmlonly</blockquote>\endhtmlonly | |
| 54 * The first option is a valid <STRONG>ISO | |
| 55 * Language Code.</STRONG> These codes are the lower-case two-letter | |
| 56 * codes as defined by ISO-639. | |
| 57 * You can find a full list of these codes at a number of sites, such as: | |
| 58 * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> | |
| 59 * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</a> | |
| 60 * | |
| 61 * <P> | |
| 62 * The second option includes an additonal <STRONG>ISO Country | |
| 63 * Code.</STRONG> These codes are the upper-case two-letter codes | |
| 64 * as defined by ISO-3166. | |
| 65 * You can find a full list of these codes at a number of sites, such as: | |
| 66 * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> | |
| 67 * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</a> | |
| 68 * | |
| 69 * <P> | |
| 70 * The third option requires another additonal information--the | |
| 71 * <STRONG>Variant.</STRONG> | |
| 72 * The Variant codes are vendor and browser-specific. | |
| 73 * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. | |
| 74 * Where there are two variants, separate them with an underscore, and | |
| 75 * put the most important one first. For | |
| 76 * example, a Traditional Spanish collation might be referenced, with | |
| 77 * "ES", "ES", "Traditional_WIN". | |
| 78 * | |
| 79 * <P> | |
| 80 * Because a <code>Locale</code> is just an identifier for a region, | |
| 81 * no validity check is performed when you specify a <code>Locale</code>. | |
| 82 * If you want to see whether particular resources are available for the | |
| 83 * <code>Locale</code> you asked for, you must query those resources. For | |
| 84 * example, ask the <code>UNumberFormat</code> for the locales it supports | |
| 85 * using its <code>getAvailable</code> method. | |
| 86 * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular | |
| 87 * locale, you get back the best available match, not necessarily | |
| 88 * precisely what you asked for. For more information, look at | |
| 89 * <code>UResourceBundle</code>. | |
| 90 * | |
| 91 * <P> | |
| 92 * The <code>Locale</code> provides a number of convenient constants | |
| 93 * that you can use to specify the commonly used | |
| 94 * locales. For example, the following refers to a locale | |
| 95 * for the United States: | |
| 96 * \htmlonly<blockquote>\endhtmlonly | |
| 97 * <pre> | |
| 98 * \code | |
| 99 * ULOC_US | |
| 100 * \endcode | |
| 101 * </pre> | |
| 102 * \htmlonly</blockquote>\endhtmlonly | |
| 103 * | |
| 104 * <P> | |
| 105 * Once you've specified a locale you can query it for information about | |
| 106 * itself. Use <code>uloc_getCountry</code> to get the ISO Country Code and | |
| 107 * <code>uloc_getLanguage</code> to get the ISO Language Code. You can | |
| 108 * use <code>uloc_getDisplayCountry</code> to get the | |
| 109 * name of the country suitable for displaying to the user. Similarly, | |
| 110 * you can use <code>uloc_getDisplayLanguage</code> to get the name of | |
| 111 * the language suitable for displaying to the user. Interestingly, | |
| 112 * the <code>uloc_getDisplayXXX</code> methods are themselves locale-sensitive | |
| 113 * and have two versions: one that uses the default locale and one | |
| 114 * that takes a locale as an argument and displays the name or country in | |
| 115 * a language appropriate to that locale. | |
| 116 * | |
| 117 * <P> | |
| 118 * The ICU provides a number of services that perform locale-sensitive | |
| 119 * operations. For example, the <code>unum_xxx</code> functions format | |
| 120 * numbers, currency, or percentages in a locale-sensitive manner. | |
| 121 * </P> | |
| 122 * \htmlonly<blockquote>\endhtmlonly | |
| 123 * <pre> | |
| 124 * \code | |
| 125 * UErrorCode success = U_ZERO_ERROR; | |
| 126 * UNumberFormat *nf; | |
| 127 * const char* myLocale = "fr_FR"; | |
| 128 * | |
| 129 * nf = unum_open( UNUM_DEFAULT, NULL, success ); | |
| 130 * unum_close(nf); | |
| 131 * nf = unum_open( UNUM_CURRENCY, NULL, success ); | |
| 132 * unum_close(nf); | |
| 133 * nf = unum_open( UNUM_PERCENT, NULL, success ); | |
| 134 * unum_close(nf); | |
| 135 * \endcode | |
| 136 * </pre> | |
| 137 * \htmlonly</blockquote>\endhtmlonly | |
| 138 * Each of these methods has two variants; one with an explicit locale | |
| 139 * and one without; the latter using the default locale. | |
| 140 * \htmlonly<blockquote>\endhtmlonly | |
| 141 * <pre> | |
| 142 * \code | |
| 143 * | |
| 144 * nf = unum_open( UNUM_DEFAULT, myLocale, success ); | |
| 145 * unum_close(nf); | |
| 146 * nf = unum_open( UNUM_CURRENCY, myLocale, success ); | |
| 147 * unum_close(nf); | |
| 148 * nf = unum_open( UNUM_PERCENT, myLocale, success ); | |
| 149 * unum_close(nf); | |
| 150 * \endcode | |
| 151 * </pre> | |
| 152 * \htmlonly</blockquote>\endhtmlonly | |
| 153 * A <code>Locale</code> is the mechanism for identifying the kind of services | |
| 154 * (<code>UNumberFormat</code>) that you would like to get. The locale is | |
| 155 * <STRONG>just</STRONG> a mechanism for identifying these services. | |
| 156 * | |
| 157 * <P> | |
| 158 * Each international serivce that performs locale-sensitive operations | |
| 159 * allows you | |
| 160 * to get all the available objects of that type. You can sift | |
| 161 * through these objects by language, country, or variant, | |
| 162 * and use the display names to present a menu to the user. | |
| 163 * For example, you can create a menu of all the collation objects | |
| 164 * suitable for a given language. Such classes implement these | |
| 165 * three class methods: | |
| 166 * \htmlonly<blockquote>\endhtmlonly | |
| 167 * <pre> | |
| 168 * \code | |
| 169 * const char* uloc_getAvailable(int32_t index); | |
| 170 * int32_t uloc_countAvailable(); | |
| 171 * int32_t | |
| 172 * uloc_getDisplayName(const char* localeID, | |
| 173 * const char* inLocaleID, | |
| 174 * UChar* result, | |
| 175 * int32_t maxResultSize, | |
| 176 * UErrorCode* err); | |
| 177 * | |
| 178 * \endcode | |
| 179 * </pre> | |
| 180 * \htmlonly</blockquote>\endhtmlonly | |
| 181 * <P> | |
| 182 * Concerning POSIX/RFC1766 Locale IDs, | |
| 183 * the getLanguage/getCountry/getVariant/getName functions do understand | |
| 184 * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT | |
| 185 * and if there is not an ICU-stype variant, uloc_getVariant() for example | |
| 186 * will return the one listed after the \@at sign. As well, the hyphen | |
| 187 * "-" is recognized as a country/variant separator similarly to RFC1766. | |
| 188 * So for example, "en-us" will be interpreted as en_US. | |
| 189 * As a result, uloc_getName() is far from a no-op, and will have the | |
| 190 * effect of converting POSIX/RFC1766 IDs into ICU form, although it does | |
| 191 * NOT map any of the actual codes (i.e. russian->ru) in any way. | |
| 192 * Applications should call uloc_getName() at the point where a locale ID | |
| 193 * is coming from an external source (user entry, OS, web browser) | |
| 194 * and pass the resulting string to other ICU functions. For example, | |
| 195 * don't use de-de\@EURO as an argument to resourcebundle. | |
| 196 * | |
| 197 * @see UResourceBundle | |
| 198 */ | |
| 199 | |
| 200 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 201 #define ULOC_CHINESE "zh" | |
| 202 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 203 #define ULOC_ENGLISH "en" | |
| 204 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 205 #define ULOC_FRENCH "fr" | |
| 206 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 207 #define ULOC_GERMAN "de" | |
| 208 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 209 #define ULOC_ITALIAN "it" | |
| 210 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 211 #define ULOC_JAPANESE "ja" | |
| 212 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 213 #define ULOC_KOREAN "ko" | |
| 214 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 215 #define ULOC_SIMPLIFIED_CHINESE "zh_CN" | |
| 216 /** Useful constant for this language. @stable ICU 2.0 */ | |
| 217 #define ULOC_TRADITIONAL_CHINESE "zh_TW" | |
| 218 | |
| 219 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 220 #define ULOC_CANADA "en_CA" | |
| 221 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 222 #define ULOC_CANADA_FRENCH "fr_CA" | |
| 223 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 224 #define ULOC_CHINA "zh_CN" | |
| 225 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 226 #define ULOC_PRC "zh_CN" | |
| 227 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 228 #define ULOC_FRANCE "fr_FR" | |
| 229 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 230 #define ULOC_GERMANY "de_DE" | |
| 231 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 232 #define ULOC_ITALY "it_IT" | |
| 233 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 234 #define ULOC_JAPAN "ja_JP" | |
| 235 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 236 #define ULOC_KOREA "ko_KR" | |
| 237 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 238 #define ULOC_TAIWAN "zh_TW" | |
| 239 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 240 #define ULOC_UK "en_GB" | |
| 241 /** Useful constant for this country/region. @stable ICU 2.0 */ | |
| 242 #define ULOC_US "en_US" | |
| 243 | |
| 244 /** | |
| 245 * Useful constant for the maximum size of the language part of a locale ID. | |
| 246 * (including the terminating NULL). | |
| 247 * @stable ICU 2.0 | |
| 248 */ | |
| 249 #define ULOC_LANG_CAPACITY 12 | |
| 250 | |
| 251 /** | |
| 252 * Useful constant for the maximum size of the country part of a locale ID | |
| 253 * (including the terminating NULL). | |
| 254 * @stable ICU 2.0 | |
| 255 */ | |
| 256 #define ULOC_COUNTRY_CAPACITY 4 | |
| 257 /** | |
| 258 * Useful constant for the maximum size of the whole locale ID | |
| 259 * (including the terminating NULL and all keywords). | |
| 260 * @stable ICU 2.0 | |
| 261 */ | |
| 262 #define ULOC_FULLNAME_CAPACITY 157 | |
| 263 | |
| 264 /** | |
| 265 * Useful constant for the maximum size of the script part of a locale ID | |
| 266 * (including the terminating NULL). | |
| 267 * @stable ICU 2.8 | |
| 268 */ | |
| 269 #define ULOC_SCRIPT_CAPACITY 6 | |
| 270 | |
| 271 /** | |
| 272 * Useful constant for the maximum size of keywords in a locale | |
| 273 * @stable ICU 2.8 | |
| 274 */ | |
| 275 #define ULOC_KEYWORDS_CAPACITY 50 | |
| 276 | |
| 277 /** | |
| 278 * Useful constant for the maximum total size of keywords and their values in a
locale | |
| 279 * @stable ICU 2.8 | |
| 280 */ | |
| 281 #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100 | |
| 282 | |
| 283 /** | |
| 284 * Invariant character separating keywords from the locale string | |
| 285 * @stable ICU 2.8 | |
| 286 */ | |
| 287 #define ULOC_KEYWORD_SEPARATOR '@' | |
| 288 | |
| 289 /** | |
| 290 * Unicode code point for '@' separating keywords from the locale string. | |
| 291 * @see ULOC_KEYWORD_SEPARATOR | |
| 292 * @draft ICU 4.6 | |
| 293 */ | |
| 294 #define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40 | |
| 295 | |
| 296 /** | |
| 297 * Invariant character for assigning value to a keyword | |
| 298 * @stable ICU 2.8 | |
| 299 */ | |
| 300 #define ULOC_KEYWORD_ASSIGN '=' | |
| 301 | |
| 302 /** | |
| 303 * Unicode code point for '=' for assigning value to a keyword. | |
| 304 * @see ULOC_KEYWORD_ASSIGN | |
| 305 * @draft ICU 4.6 | |
| 306 */ | |
| 307 #define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D | |
| 308 | |
| 309 /** | |
| 310 * Invariant character separating keywords | |
| 311 * @stable ICU 2.8 | |
| 312 */ | |
| 313 #define ULOC_KEYWORD_ITEM_SEPARATOR ';' | |
| 314 | |
| 315 /** | |
| 316 * Unicode code point for ';' separating keywords | |
| 317 * @see ULOC_KEYWORD_ITEM_SEPARATOR | |
| 318 * @draft ICU 4.6 | |
| 319 */ | |
| 320 #define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B | |
| 321 | |
| 322 /** | |
| 323 * Constants for *_getLocale() | |
| 324 * Allow user to select whether she wants information on | |
| 325 * requested, valid or actual locale. | |
| 326 * For example, a collator for "en_US_CALIFORNIA" was | |
| 327 * requested. In the current state of ICU (2.0), | |
| 328 * the requested locale is "en_US_CALIFORNIA", | |
| 329 * the valid locale is "en_US" (most specific locale supported by ICU) | |
| 330 * and the actual locale is "root" (the collation data comes unmodified | |
| 331 * from the UCA) | |
| 332 * The locale is considered supported by ICU if there is a core ICU bundle | |
| 333 * for that locale (although it may be empty). | |
| 334 * @stable ICU 2.1 | |
| 335 */ | |
| 336 typedef enum { | |
| 337 /** This is locale the data actually comes from | |
| 338 * @stable ICU 2.1 | |
| 339 */ | |
| 340 ULOC_ACTUAL_LOCALE = 0, | |
| 341 /** This is the most specific locale supported by ICU | |
| 342 * @stable ICU 2.1 | |
| 343 */ | |
| 344 ULOC_VALID_LOCALE = 1, | |
| 345 | |
| 346 #ifndef U_HIDE_DEPRECATED_API | |
| 347 /** This is the requested locale | |
| 348 * @deprecated ICU 2.8 | |
| 349 */ | |
| 350 ULOC_REQUESTED_LOCALE = 2, | |
| 351 #endif /* U_HIDE_DEPRECATED_API */ | |
| 352 | |
| 353 ULOC_DATA_LOCALE_TYPE_LIMIT = 3 | |
| 354 } ULocDataLocaleType ; | |
| 355 | |
| 356 | |
| 357 /** | |
| 358 * Gets ICU's default locale. | |
| 359 * The returned string is a snapshot in time, and will remain valid | |
| 360 * and unchanged even when uloc_setDefault() is called. | |
| 361 * The returned storage is owned by ICU, and must not be altered or deleted | |
| 362 * by the caller. | |
| 363 * | |
| 364 * @return the ICU default locale | |
| 365 * @system | |
| 366 * @stable ICU 2.0 | |
| 367 */ | |
| 368 U_STABLE const char* U_EXPORT2 | |
| 369 uloc_getDefault(void); | |
| 370 | |
| 371 /** | |
| 372 * Sets ICU's default locale. | |
| 373 * By default (without calling this function), ICU's default locale will be b
ased | |
| 374 * on information obtained from the underlying system environment. | |
| 375 * <p> | |
| 376 * Changes to ICU's default locale do not propagate back to the | |
| 377 * system environment. | |
| 378 * <p> | |
| 379 * Changes to ICU's default locale to not affect any ICU services that | |
| 380 * may already be open based on the previous default locale value. | |
| 381 * | |
| 382 * @param localeID the new ICU default locale. A value of NULL will try to get | |
| 383 * the system's default locale. | |
| 384 * @param status the error information if the setting of default locale fails | |
| 385 * @system | |
| 386 * @stable ICU 2.0 | |
| 387 */ | |
| 388 U_STABLE void U_EXPORT2 | |
| 389 uloc_setDefault(const char* localeID, | |
| 390 UErrorCode* status); | |
| 391 | |
| 392 /** | |
| 393 * Gets the language code for the specified locale. | |
| 394 * | |
| 395 * @param localeID the locale to get the ISO language code with | |
| 396 * @param language the language code for localeID | |
| 397 * @param languageCapacity the size of the language buffer to store the | |
| 398 * language code with | |
| 399 * @param err error information if retrieving the language code failed | |
| 400 * @return the actual buffer size needed for the language code. If it's greater
| |
| 401 * than languageCapacity, the returned language code will be truncated. | |
| 402 * @stable ICU 2.0 | |
| 403 */ | |
| 404 U_STABLE int32_t U_EXPORT2 | |
| 405 uloc_getLanguage(const char* localeID, | |
| 406 char* language, | |
| 407 int32_t languageCapacity, | |
| 408 UErrorCode* err); | |
| 409 | |
| 410 /** | |
| 411 * Gets the script code for the specified locale. | |
| 412 * | |
| 413 * @param localeID the locale to get the ISO language code with | |
| 414 * @param script the language code for localeID | |
| 415 * @param scriptCapacity the size of the language buffer to store the | |
| 416 * language code with | |
| 417 * @param err error information if retrieving the language code failed | |
| 418 * @return the actual buffer size needed for the language code. If it's greater
| |
| 419 * than scriptCapacity, the returned language code will be truncated. | |
| 420 * @stable ICU 2.8 | |
| 421 */ | |
| 422 U_STABLE int32_t U_EXPORT2 | |
| 423 uloc_getScript(const char* localeID, | |
| 424 char* script, | |
| 425 int32_t scriptCapacity, | |
| 426 UErrorCode* err); | |
| 427 | |
| 428 /** | |
| 429 * Gets the country code for the specified locale. | |
| 430 * | |
| 431 * @param localeID the locale to get the country code with | |
| 432 * @param country the country code for localeID | |
| 433 * @param countryCapacity the size of the country buffer to store the | |
| 434 * country code with | |
| 435 * @param err error information if retrieving the country code failed | |
| 436 * @return the actual buffer size needed for the country code. If it's greater | |
| 437 * than countryCapacity, the returned country code will be truncated. | |
| 438 * @stable ICU 2.0 | |
| 439 */ | |
| 440 U_STABLE int32_t U_EXPORT2 | |
| 441 uloc_getCountry(const char* localeID, | |
| 442 char* country, | |
| 443 int32_t countryCapacity, | |
| 444 UErrorCode* err); | |
| 445 | |
| 446 /** | |
| 447 * Gets the variant code for the specified locale. | |
| 448 * | |
| 449 * @param localeID the locale to get the variant code with | |
| 450 * @param variant the variant code for localeID | |
| 451 * @param variantCapacity the size of the variant buffer to store the | |
| 452 * variant code with | |
| 453 * @param err error information if retrieving the variant code failed | |
| 454 * @return the actual buffer size needed for the variant code. If it's greater | |
| 455 * than variantCapacity, the returned variant code will be truncated. | |
| 456 * @stable ICU 2.0 | |
| 457 */ | |
| 458 U_STABLE int32_t U_EXPORT2 | |
| 459 uloc_getVariant(const char* localeID, | |
| 460 char* variant, | |
| 461 int32_t variantCapacity, | |
| 462 UErrorCode* err); | |
| 463 | |
| 464 | |
| 465 /** | |
| 466 * Gets the full name for the specified locale. | |
| 467 * Note: This has the effect of 'canonicalizing' the ICU locale ID to | |
| 468 * a certain extent. Upper and lower case are set as needed. | |
| 469 * It does NOT map aliased names in any way. | |
| 470 * See the top of this header file. | |
| 471 * This API supports preflighting. | |
| 472 * | |
| 473 * @param localeID the locale to get the full name with | |
| 474 * @param name fill in buffer for the name without keywords. | |
| 475 * @param nameCapacity capacity of the fill in buffer. | |
| 476 * @param err error information if retrieving the full name failed | |
| 477 * @return the actual buffer size needed for the full name. If it's greater | |
| 478 * than nameCapacity, the returned full name will be truncated. | |
| 479 * @stable ICU 2.0 | |
| 480 */ | |
| 481 U_STABLE int32_t U_EXPORT2 | |
| 482 uloc_getName(const char* localeID, | |
| 483 char* name, | |
| 484 int32_t nameCapacity, | |
| 485 UErrorCode* err); | |
| 486 | |
| 487 /** | |
| 488 * Gets the full name for the specified locale. | |
| 489 * Note: This has the effect of 'canonicalizing' the string to | |
| 490 * a certain extent. Upper and lower case are set as needed, | |
| 491 * and if the components were in 'POSIX' format they are changed to | |
| 492 * ICU format. It does NOT map aliased names in any way. | |
| 493 * See the top of this header file. | |
| 494 * | |
| 495 * @param localeID the locale to get the full name with | |
| 496 * @param name the full name for localeID | |
| 497 * @param nameCapacity the size of the name buffer to store the | |
| 498 * full name with | |
| 499 * @param err error information if retrieving the full name failed | |
| 500 * @return the actual buffer size needed for the full name. If it's greater | |
| 501 * than nameCapacity, the returned full name will be truncated. | |
| 502 * @stable ICU 2.8 | |
| 503 */ | |
| 504 U_STABLE int32_t U_EXPORT2 | |
| 505 uloc_canonicalize(const char* localeID, | |
| 506 char* name, | |
| 507 int32_t nameCapacity, | |
| 508 UErrorCode* err); | |
| 509 | |
| 510 /** | |
| 511 * Gets the ISO language code for the specified locale. | |
| 512 * | |
| 513 * @param localeID the locale to get the ISO language code with | |
| 514 * @return language the ISO language code for localeID | |
| 515 * @stable ICU 2.0 | |
| 516 */ | |
| 517 U_STABLE const char* U_EXPORT2 | |
| 518 uloc_getISO3Language(const char* localeID); | |
| 519 | |
| 520 | |
| 521 /** | |
| 522 * Gets the ISO country code for the specified locale. | |
| 523 * | |
| 524 * @param localeID the locale to get the ISO country code with | |
| 525 * @return country the ISO country code for localeID | |
| 526 * @stable ICU 2.0 | |
| 527 */ | |
| 528 U_STABLE const char* U_EXPORT2 | |
| 529 uloc_getISO3Country(const char* localeID); | |
| 530 | |
| 531 /** | |
| 532 * Gets the Win32 LCID value for the specified locale. | |
| 533 * If the ICU locale is not recognized by Windows, 0 will be returned. | |
| 534 * | |
| 535 * @param localeID the locale to get the Win32 LCID value with | |
| 536 * @return country the Win32 LCID for localeID | |
| 537 * @stable ICU 2.0 | |
| 538 */ | |
| 539 U_STABLE uint32_t U_EXPORT2 | |
| 540 uloc_getLCID(const char* localeID); | |
| 541 | |
| 542 /** | |
| 543 * Gets the language name suitable for display for the specified locale. | |
| 544 * | |
| 545 * @param locale the locale to get the ISO language code with | |
| 546 * @param displayLocale Specifies the locale to be used to display the name. In
other words, | |
| 547 * if the locale's language code is "en", passing Locale::getFre
nch() for | |
| 548 * inLocale would result in "Anglais", while passing Locale::get
German() | |
| 549 * for inLocale would result in "Englisch". | |
| 550 * @param language the displayable language code for localeID | |
| 551 * @param languageCapacity the size of the language buffer to store the | |
| 552 * displayable language code with | |
| 553 * @param status error information if retrieving the displayable language code f
ailed | |
| 554 * @return the actual buffer size needed for the displayable language code. If
it's greater | |
| 555 * than languageCapacity, the returned language code will be truncated. | |
| 556 * @stable ICU 2.0 | |
| 557 */ | |
| 558 U_STABLE int32_t U_EXPORT2 | |
| 559 uloc_getDisplayLanguage(const char* locale, | |
| 560 const char* displayLocale, | |
| 561 UChar* language, | |
| 562 int32_t languageCapacity, | |
| 563 UErrorCode* status); | |
| 564 | |
| 565 /** | |
| 566 * Gets the script name suitable for display for the specified locale. | |
| 567 * | |
| 568 * @param locale the locale to get the displayable script code with. NULL may be
used to specify the default. | |
| 569 * @param displayLocale Specifies the locale to be used to display the name. In
other words, | |
| 570 * if the locale's language code is "en", passing Locale::getFre
nch() for | |
| 571 * inLocale would result in "", while passing Locale::getGerman(
) | |
| 572 * for inLocale would result in "". NULL may be used to specify
the default. | |
| 573 * @param script the displayable country code for localeID | |
| 574 * @param scriptCapacity the size of the script buffer to store the | |
| 575 * displayable script code with | |
| 576 * @param status error information if retrieving the displayable script code fai
led | |
| 577 * @return the actual buffer size needed for the displayable script code. If it
's greater | |
| 578 * than scriptCapacity, the returned displayable script code will be truncated.
| |
| 579 * @stable ICU 2.8 | |
| 580 */ | |
| 581 U_STABLE int32_t U_EXPORT2 | |
| 582 uloc_getDisplayScript(const char* locale, | |
| 583 const char* displayLocale, | |
| 584 UChar* script, | |
| 585 int32_t scriptCapacity, | |
| 586 UErrorCode* status); | |
| 587 | |
| 588 /** | |
| 589 * Gets the country name suitable for display for the specified locale. | |
| 590 * | |
| 591 * @param locale the locale to get the displayable country code with. NULL may b
e used to specify the default. | |
| 592 * @param displayLocale Specifies the locale to be used to display the name. In
other words, | |
| 593 * if the locale's language code is "en", passing Locale::getFre
nch() for | |
| 594 * inLocale would result in "Anglais", while passing Locale::get
German() | |
| 595 * for inLocale would result in "Englisch". NULL may be used to
specify the default. | |
| 596 * @param country the displayable country code for localeID | |
| 597 * @param countryCapacity the size of the country buffer to store the | |
| 598 * displayable country code with | |
| 599 * @param status error information if retrieving the displayable country code fa
iled | |
| 600 * @return the actual buffer size needed for the displayable country code. If i
t's greater | |
| 601 * than countryCapacity, the returned displayable country code will be truncated
. | |
| 602 * @stable ICU 2.0 | |
| 603 */ | |
| 604 U_STABLE int32_t U_EXPORT2 | |
| 605 uloc_getDisplayCountry(const char* locale, | |
| 606 const char* displayLocale, | |
| 607 UChar* country, | |
| 608 int32_t countryCapacity, | |
| 609 UErrorCode* status); | |
| 610 | |
| 611 | |
| 612 /** | |
| 613 * Gets the variant name suitable for display for the specified locale. | |
| 614 * | |
| 615 * @param locale the locale to get the displayable variant code with. NULL may b
e used to specify the default. | |
| 616 * @param displayLocale Specifies the locale to be used to display the name. In
other words, | |
| 617 * if the locale's language code is "en", passing Locale::getFre
nch() for | |
| 618 * inLocale would result in "Anglais", while passing Locale::get
German() | |
| 619 * for inLocale would result in "Englisch". NULL may be used to
specify the default. | |
| 620 * @param variant the displayable variant code for localeID | |
| 621 * @param variantCapacity the size of the variant buffer to store the | |
| 622 * displayable variant code with | |
| 623 * @param status error information if retrieving the displayable variant code fa
iled | |
| 624 * @return the actual buffer size needed for the displayable variant code. If i
t's greater | |
| 625 * than variantCapacity, the returned displayable variant code will be truncated
. | |
| 626 * @stable ICU 2.0 | |
| 627 */ | |
| 628 U_STABLE int32_t U_EXPORT2 | |
| 629 uloc_getDisplayVariant(const char* locale, | |
| 630 const char* displayLocale, | |
| 631 UChar* variant, | |
| 632 int32_t variantCapacity, | |
| 633 UErrorCode* status); | |
| 634 | |
| 635 /** | |
| 636 * Gets the keyword name suitable for display for the specified locale. | |
| 637 * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the disp
lay | |
| 638 * string for the keyword collation. | |
| 639 * Usage: | |
| 640 * <code> | |
| 641 * UErrorCode status = U_ZERO_ERROR; | |
| 642 * const char* keyword =NULL; | |
| 643 * int32_t keywordLen = 0; | |
| 644 * int32_t keywordCount = 0; | |
| 645 * UChar displayKeyword[256]; | |
| 646 * int32_t displayKeywordLen = 0; | |
| 647 * UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;c
alendar=TRADITIONAL", &status); | |
| 648 * for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; k
eywordCount--){ | |
| 649 * if(U_FAILURE(status)){ | |
| 650 * ...something went wrong so handle the error... | |
| 651 * break; | |
| 652 * } | |
| 653 * // the uenum_next returns NUL terminated string | |
| 654 * keyword = uenum_next(keywordEnum, &keywordLen, &status); | |
| 655 * displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", display
Keyword, 256); | |
| 656 * ... do something interesting ..... | |
| 657 * } | |
| 658 * uenum_close(keywordEnum); | |
| 659 * </code> | |
| 660 * @param keyword The keyword whose display string needs to be returne
d. | |
| 661 * @param displayLocale Specifies the locale to be used to display the name.
In other words, | |
| 662 * if the locale's language code is "en", passing Local
e::getFrench() for | |
| 663 * inLocale would result in "Anglais", while passing Lo
cale::getGerman() | |
| 664 * for inLocale would result in "Englisch". NULL may be
used to specify the default. | |
| 665 * @param dest the buffer to which the displayable keyword should b
e written. | |
| 666 * @param destCapacity The size of the buffer (number of UChars). If it is
0, then | |
| 667 * dest may be NULL and the function will only return t
he length of the | |
| 668 * result without writing any of the result string (pre
-flighting). | |
| 669 * @param status error information if retrieving the displayable stri
ng failed. | |
| 670 * Should not be NULL and should not indicate failure o
n entry. | |
| 671 * @return the actual buffer size needed for the displayable variant code. | |
| 672 * @see #uloc_openKeywords | |
| 673 * @stable ICU 2.8 | |
| 674 */ | |
| 675 U_STABLE int32_t U_EXPORT2 | |
| 676 uloc_getDisplayKeyword(const char* keyword, | |
| 677 const char* displayLocale, | |
| 678 UChar* dest, | |
| 679 int32_t destCapacity, | |
| 680 UErrorCode* status); | |
| 681 /** | |
| 682 * Gets the value of the keyword suitable for display for the specified locale. | |
| 683 * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the disp
lay | |
| 684 * string for PHONEBOOK, in the display locale, when "collation" is specified as
the keyword. | |
| 685 * | |
| 686 * @param locale The locale to get the displayable variant code with.
NULL may be used to specify the default. | |
| 687 * @param keyword The keyword for whose value should be used. | |
| 688 * @param displayLocale Specifies the locale to be used to display the name.
In other words, | |
| 689 * if the locale's language code is "en", passing Local
e::getFrench() for | |
| 690 * inLocale would result in "Anglais", while passing Lo
cale::getGerman() | |
| 691 * for inLocale would result in "Englisch". NULL may be
used to specify the default. | |
| 692 * @param dest the buffer to which the displayable keyword should b
e written. | |
| 693 * @param destCapacity The size of the buffer (number of UChars). If it is
0, then | |
| 694 * dest may be NULL and the function will only return t
he length of the | |
| 695 * result without writing any of the result string (pre
-flighting). | |
| 696 * @param status error information if retrieving the displayable stri
ng failed. | |
| 697 * Should not be NULL and must not indicate failure on
entry. | |
| 698 * @return the actual buffer size needed for the displayable variant code. | |
| 699 * @stable ICU 2.8 | |
| 700 */ | |
| 701 U_STABLE int32_t U_EXPORT2 | |
| 702 uloc_getDisplayKeywordValue( const char* locale, | |
| 703 const char* keyword, | |
| 704 const char* displayLocale, | |
| 705 UChar* dest, | |
| 706 int32_t destCapacity, | |
| 707 UErrorCode* status); | |
| 708 /** | |
| 709 * Gets the full name suitable for display for the specified locale. | |
| 710 * | |
| 711 * @param localeID the locale to get the displayable name with. NULL may be used
to specify the default. | |
| 712 * @param inLocaleID Specifies the locale to be used to display the name. In ot
her words, | |
| 713 * if the locale's language code is "en", passing Locale::getF
rench() for | |
| 714 * inLocale would result in "Anglais", while passing Locale::g
etGerman() | |
| 715 * for inLocale would result in "Englisch". NULL may be used t
o specify the default. | |
| 716 * @param result the displayable name for localeID | |
| 717 * @param maxResultSize the size of the name buffer to store the | |
| 718 * displayable full name with | |
| 719 * @param err error information if retrieving the displayable name failed | |
| 720 * @return the actual buffer size needed for the displayable name. If it's grea
ter | |
| 721 * than maxResultSize, the returned displayable name will be truncated. | |
| 722 * @stable ICU 2.0 | |
| 723 */ | |
| 724 U_STABLE int32_t U_EXPORT2 | |
| 725 uloc_getDisplayName(const char* localeID, | |
| 726 const char* inLocaleID, | |
| 727 UChar* result, | |
| 728 int32_t maxResultSize, | |
| 729 UErrorCode* err); | |
| 730 | |
| 731 | |
| 732 /** | |
| 733 * Gets the specified locale from a list of all available locales. | |
| 734 * The return value is a pointer to an item of | |
| 735 * a locale name array. Both this array and the pointers | |
| 736 * it contains are owned by ICU and should not be deleted or written through | |
| 737 * by the caller. The locale name is terminated by a null pointer. | |
| 738 * @param n the specific locale name index of the available locale list | |
| 739 * @return a specified locale name of all available locales | |
| 740 * @stable ICU 2.0 | |
| 741 */ | |
| 742 U_STABLE const char* U_EXPORT2 | |
| 743 uloc_getAvailable(int32_t n); | |
| 744 | |
| 745 /** | |
| 746 * Gets the size of the all available locale list. | |
| 747 * | |
| 748 * @return the size of the locale list | |
| 749 * @stable ICU 2.0 | |
| 750 */ | |
| 751 U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void); | |
| 752 | |
| 753 /** | |
| 754 * | |
| 755 * Gets a list of all available language codes defined in ISO 639. This is a po
inter | |
| 756 * to an array of pointers to arrays of char. All of these pointers are owned | |
| 757 * by ICU-- do not delete them, and do not write through them. The array is | |
| 758 * terminated with a null pointer. | |
| 759 * @return a list of all available language codes | |
| 760 * @stable ICU 2.0 | |
| 761 */ | |
| 762 U_STABLE const char* const* U_EXPORT2 | |
| 763 uloc_getISOLanguages(void); | |
| 764 | |
| 765 /** | |
| 766 * | |
| 767 * Gets a list of all available 2-letter country codes defined in ISO 639. This
is a | |
| 768 * pointer to an array of pointers to arrays of char. All of these pointers are | |
| 769 * owned by ICU-- do not delete them, and do not write through them. The array
is | |
| 770 * terminated with a null pointer. | |
| 771 * @return a list of all available country codes | |
| 772 * @stable ICU 2.0 | |
| 773 */ | |
| 774 U_STABLE const char* const* U_EXPORT2 | |
| 775 uloc_getISOCountries(void); | |
| 776 | |
| 777 /** | |
| 778 * Truncate the locale ID string to get the parent locale ID. | |
| 779 * Copies the part of the string before the last underscore. | |
| 780 * The parent locale ID will be an empty string if there is no | |
| 781 * underscore, or if there is only one underscore at localeID[0]. | |
| 782 * | |
| 783 * @param localeID Input locale ID string. | |
| 784 * @param parent Output string buffer for the parent locale ID. | |
| 785 * @param parentCapacity Size of the output buffer. | |
| 786 * @param err A UErrorCode value. | |
| 787 * @return The length of the parent locale ID. | |
| 788 * @stable ICU 2.0 | |
| 789 */ | |
| 790 U_STABLE int32_t U_EXPORT2 | |
| 791 uloc_getParent(const char* localeID, | |
| 792 char* parent, | |
| 793 int32_t parentCapacity, | |
| 794 UErrorCode* err); | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 /** | |
| 800 * Gets the full name for the specified locale. | |
| 801 * Note: This has the effect of 'canonicalizing' the string to | |
| 802 * a certain extent. Upper and lower case are set as needed, | |
| 803 * and if the components were in 'POSIX' format they are changed to | |
| 804 * ICU format. It does NOT map aliased names in any way. | |
| 805 * See the top of this header file. | |
| 806 * This API strips off the keyword part, so "de_DE\@collation=phonebook" | |
| 807 * will become "de_DE". | |
| 808 * This API supports preflighting. | |
| 809 * | |
| 810 * @param localeID the locale to get the full name with | |
| 811 * @param name fill in buffer for the name without keywords. | |
| 812 * @param nameCapacity capacity of the fill in buffer. | |
| 813 * @param err error information if retrieving the full name failed | |
| 814 * @return the actual buffer size needed for the full name. If it's greater | |
| 815 * than nameCapacity, the returned full name will be truncated. | |
| 816 * @stable ICU 2.8 | |
| 817 */ | |
| 818 U_STABLE int32_t U_EXPORT2 | |
| 819 uloc_getBaseName(const char* localeID, | |
| 820 char* name, | |
| 821 int32_t nameCapacity, | |
| 822 UErrorCode* err); | |
| 823 | |
| 824 /** | |
| 825 * Gets an enumeration of keywords for the specified locale. Enumeration | |
| 826 * must get disposed of by the client using uenum_close function. | |
| 827 * | |
| 828 * @param localeID the locale to get the variant code with | |
| 829 * @param status error information if retrieving the keywords failed | |
| 830 * @return enumeration of keywords or NULL if there are no keywords. | |
| 831 * @stable ICU 2.8 | |
| 832 */ | |
| 833 U_STABLE UEnumeration* U_EXPORT2 | |
| 834 uloc_openKeywords(const char* localeID, | |
| 835 UErrorCode* status); | |
| 836 | |
| 837 /** | |
| 838 * Get the value for a keyword. Locale name does not need to be normalized. | |
| 839 * | |
| 840 * @param localeID locale name containing the keyword ("de_DE@currency=EURO;coll
ation=PHONEBOOK") | |
| 841 * @param keywordName name of the keyword for which we want the value. Case inse
nsitive. | |
| 842 * @param buffer receiving buffer | |
| 843 * @param bufferCapacity capacity of receiving buffer | |
| 844 * @param status containing error code - buffer not big enough. | |
| 845 * @return the length of keyword value | |
| 846 * @stable ICU 2.8 | |
| 847 */ | |
| 848 U_STABLE int32_t U_EXPORT2 | |
| 849 uloc_getKeywordValue(const char* localeID, | |
| 850 const char* keywordName, | |
| 851 char* buffer, int32_t bufferCapacity, | |
| 852 UErrorCode* status); | |
| 853 | |
| 854 | |
| 855 /** | |
| 856 * Set the value of the specified keyword. | |
| 857 * NOTE: Unlike almost every other ICU function which takes a | |
| 858 * buffer, this function will NOT truncate the output text. If a | |
| 859 * BUFFER_OVERFLOW_ERROR is received, it means that the original | |
| 860 * buffer is untouched. This is done to prevent incorrect or possibly | |
| 861 * even malformed locales from being generated and used. | |
| 862 * | |
| 863 * @param keywordName name of the keyword to be set. Case insensitive. | |
| 864 * @param keywordValue value of the keyword to be set. If 0-length or | |
| 865 * NULL, will result in the keyword being removed. No error is given if | |
| 866 * that keyword does not exist. | |
| 867 * @param buffer input buffer containing locale to be modified. | |
| 868 * @param bufferCapacity capacity of receiving buffer | |
| 869 * @param status containing error code - buffer not big enough. | |
| 870 * @return the length needed for the buffer | |
| 871 * @see uloc_getKeywordValue | |
| 872 * @stable ICU 3.2 | |
| 873 */ | |
| 874 U_STABLE int32_t U_EXPORT2 | |
| 875 uloc_setKeywordValue(const char* keywordName, | |
| 876 const char* keywordValue, | |
| 877 char* buffer, int32_t bufferCapacity, | |
| 878 UErrorCode* status); | |
| 879 | |
| 880 /** | |
| 881 * enums for the return value for the character and line orientation | |
| 882 * functions. | |
| 883 * @stable ICU 4.0 | |
| 884 */ | |
| 885 typedef enum { | |
| 886 ULOC_LAYOUT_LTR = 0, /* left-to-right. */ | |
| 887 ULOC_LAYOUT_RTL = 1, /* right-to-left. */ | |
| 888 ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */ | |
| 889 ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */ | |
| 890 ULOC_LAYOUT_UNKNOWN | |
| 891 } ULayoutType; | |
| 892 | |
| 893 /** | |
| 894 * Get the layout character orientation for the specified locale. | |
| 895 * | |
| 896 * @param localeId locale name | |
| 897 * @param status Error status | |
| 898 * @return an enum indicating the layout orientation for characters. | |
| 899 * @stable ICU 4.0 | |
| 900 */ | |
| 901 U_STABLE ULayoutType U_EXPORT2 | |
| 902 uloc_getCharacterOrientation(const char* localeId, | |
| 903 UErrorCode *status); | |
| 904 | |
| 905 /** | |
| 906 * Get the layout line orientation for the specified locale. | |
| 907 * | |
| 908 * @param localeId locale name | |
| 909 * @param status Error status | |
| 910 * @return an enum indicating the layout orientation for lines. | |
| 911 * @stable ICU 4.0 | |
| 912 */ | |
| 913 U_STABLE ULayoutType U_EXPORT2 | |
| 914 uloc_getLineOrientation(const char* localeId, | |
| 915 UErrorCode *status); | |
| 916 | |
| 917 /** | |
| 918 * enums for the 'outResult' parameter return value | |
| 919 * @see uloc_acceptLanguageFromHTTP | |
| 920 * @see uloc_acceptLanguage | |
| 921 * @stable ICU 3.2 | |
| 922 */ | |
| 923 typedef enum { | |
| 924 ULOC_ACCEPT_FAILED = 0, /* No exact match was found. */ | |
| 925 ULOC_ACCEPT_VALID = 1, /* An exact match was found. */ | |
| 926 ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example, | |
| 927 Accept list contained 'ja_JP' | |
| 928 which matched available locale 'ja'. */ | |
| 929 } UAcceptResult; | |
| 930 | |
| 931 | |
| 932 /** | |
| 933 * Based on a HTTP header from a web browser and a list of available locales, | |
| 934 * determine an acceptable locale for the user. | |
| 935 * @param result - buffer to accept the result locale | |
| 936 * @param resultAvailable the size of the result buffer. | |
| 937 * @param outResult - An out parameter that contains the fallback status | |
| 938 * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP. | |
| 939 * @param availableLocales - list of available locales to match | |
| 940 * @param status Error status, may be BUFFER_OVERFLOW_ERROR | |
| 941 * @return length needed for the locale. | |
| 942 * @stable ICU 3.2 | |
| 943 */ | |
| 944 U_STABLE int32_t U_EXPORT2 | |
| 945 uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, | |
| 946 UAcceptResult *outResult, | |
| 947 const char *httpAcceptLanguage, | |
| 948 UEnumeration* availableLocales, | |
| 949 UErrorCode *status); | |
| 950 | |
| 951 /** | |
| 952 * Based on a list of available locales, | |
| 953 * determine an acceptable locale for the user. | |
| 954 * @param result - buffer to accept the result locale | |
| 955 * @param resultAvailable the size of the result buffer. | |
| 956 * @param outResult - An out parameter that contains the fallback status | |
| 957 * @param acceptList - list of acceptable languages | |
| 958 * @param acceptListCount - count of acceptList items | |
| 959 * @param availableLocales - list of available locales to match | |
| 960 * @param status Error status, may be BUFFER_OVERFLOW_ERROR | |
| 961 * @return length needed for the locale. | |
| 962 * @stable ICU 3.2 | |
| 963 */ | |
| 964 U_STABLE int32_t U_EXPORT2 | |
| 965 uloc_acceptLanguage(char *result, int32_t resultAvailable, | |
| 966 UAcceptResult *outResult, const char **acceptList, | |
| 967 int32_t acceptListCount, | |
| 968 UEnumeration* availableLocales, | |
| 969 UErrorCode *status); | |
| 970 | |
| 971 | |
| 972 /** | |
| 973 * Gets the ICU locale ID for the specified Win32 LCID value. | |
| 974 * | |
| 975 * @param hostID the Win32 LCID to translate | |
| 976 * @param locale the output buffer for the ICU locale ID, which will be NUL-term
inated | |
| 977 * if there is room. | |
| 978 * @param localeCapacity the size of the output buffer | |
| 979 * @param status an error is returned if the LCID is unrecognized or the output
buffer | |
| 980 * is too small | |
| 981 * @return actual the actual size of the locale ID, not including NUL-terminatio
n | |
| 982 * @stable ICU 3.8 | |
| 983 */ | |
| 984 U_STABLE int32_t U_EXPORT2 | |
| 985 uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity, | |
| 986 UErrorCode *status); | |
| 987 | |
| 988 | |
| 989 /** | |
| 990 * Add the likely subtags for a provided locale ID, per the algorithm described | |
| 991 * in the following CLDR technical report: | |
| 992 * | |
| 993 * http://www.unicode.org/reports/tr35/#Likely_Subtags | |
| 994 * | |
| 995 * If localeID is already in the maximal form, or there is no data available | |
| 996 * for maximization, it will be copied to the output buffer. For example, | |
| 997 * "und-Zzzz" cannot be maximized, since there is no reasonable maximization. | |
| 998 * | |
| 999 * Examples: | |
| 1000 * | |
| 1001 * "en" maximizes to "en_Latn_US" | |
| 1002 * | |
| 1003 * "de" maximizes to "de_Latn_US" | |
| 1004 * | |
| 1005 * "sr" maximizes to "sr_Cyrl_RS" | |
| 1006 * | |
| 1007 * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) | |
| 1008 * | |
| 1009 * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.) | |
| 1010 * | |
| 1011 * @param localeID The locale to maximize | |
| 1012 * @param maximizedLocaleID The maximized locale | |
| 1013 * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer | |
| 1014 * @param err Error information if maximizing the locale failed. If the length | |
| 1015 * of the localeID and the null-terminator is greater than the maximum allowed s
ize, | |
| 1016 * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERRO
R. | |
| 1017 * @return The actual buffer size needed for the maximized locale. If it's | |
| 1018 * greater than maximizedLocaleIDCapacity, the returned ID will be truncated. | |
| 1019 * On error, the return value is -1. | |
| 1020 * @stable ICU 4.0 | |
| 1021 */ | |
| 1022 U_STABLE int32_t U_EXPORT2 | |
| 1023 uloc_addLikelySubtags(const char* localeID, | |
| 1024 char* maximizedLocaleID, | |
| 1025 int32_t maximizedLocaleIDCapacity, | |
| 1026 UErrorCode* err); | |
| 1027 | |
| 1028 | |
| 1029 /** | |
| 1030 * Minimize the subtags for a provided locale ID, per the algorithm described | |
| 1031 * in the following CLDR technical report: | |
| 1032 * | |
| 1033 * http://www.unicode.org/reports/tr35/#Likely_Subtags | |
| 1034 * | |
| 1035 * If localeID is already in the minimal form, or there is no data available | |
| 1036 * for minimization, it will be copied to the output buffer. Since the | |
| 1037 * minimization algorithm relies on proper maximization, see the comments | |
| 1038 * for uloc_addLikelySubtags for reasons why there might not be any data. | |
| 1039 * | |
| 1040 * Examples: | |
| 1041 * | |
| 1042 * "en_Latn_US" minimizes to "en" | |
| 1043 * | |
| 1044 * "de_Latn_US" minimizes to "de" | |
| 1045 * | |
| 1046 * "sr_Cyrl_RS" minimizes to "sr" | |
| 1047 * | |
| 1048 * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the | |
| 1049 * script, and minimizing to "zh" would imply "zh_Hans_CN".) | |
| 1050 * | |
| 1051 * @param localeID The locale to minimize | |
| 1052 * @param minimizedLocaleID The minimized locale | |
| 1053 * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer | |
| 1054 * @param err Error information if minimizing the locale failed. If the length | |
| 1055 * of the localeID and the null-terminator is greater than the maximum allowed s
ize, | |
| 1056 * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERRO
R. | |
| 1057 * @return The actual buffer size needed for the minimized locale. If it's | |
| 1058 * greater than minimizedLocaleIDCapacity, the returned ID will be truncated. | |
| 1059 * On error, the return value is -1. | |
| 1060 * @stable ICU 4.0 | |
| 1061 */ | |
| 1062 U_STABLE int32_t U_EXPORT2 | |
| 1063 uloc_minimizeSubtags(const char* localeID, | |
| 1064 char* minimizedLocaleID, | |
| 1065 int32_t minimizedLocaleIDCapacity, | |
| 1066 UErrorCode* err); | |
| 1067 | |
| 1068 /** | |
| 1069 * Returns a locale ID for the specified BCP47 language tag string. | |
| 1070 * If the specified language tag contains any ill-formed subtags, | |
| 1071 * the first such subtag and all following subtags are ignored. | |
| 1072 * <p> | |
| 1073 * This implements the 'Language-Tag' production of BCP47, and so | |
| 1074 * supports grandfathered (regular and irregular) as well as private | |
| 1075 * use language tags. Private use tags are represented as 'x-whatever', | |
| 1076 * and grandfathered tags are converted to their canonical replacements | |
| 1077 * where they exist. Note that a few grandfathered tags have no modern | |
| 1078 * replacement, these will be converted using the fallback described in | |
| 1079 * the first paragraph, so some information might be lost. | |
| 1080 * @param langtag the input BCP47 language tag. | |
| 1081 * @param localeID the output buffer receiving a locale ID for the | |
| 1082 * specified BCP47 language tag. | |
| 1083 * @param localeIDCapacity the size of the locale ID output buffer. | |
| 1084 * @param parsedLength if not NULL, succsessfully parsed length | |
| 1085 * for the input language tag is set. | |
| 1086 * @param err error information if receiving the locald ID | |
| 1087 * failed. | |
| 1088 * @return the length of the locale ID. | |
| 1089 * @draft ICU 4.2 | |
| 1090 */ | |
| 1091 U_DRAFT int32_t U_EXPORT2 | |
| 1092 uloc_forLanguageTag(const char* langtag, | |
| 1093 char* localeID, | |
| 1094 int32_t localeIDCapacity, | |
| 1095 int32_t* parsedLength, | |
| 1096 UErrorCode* err); | |
| 1097 | |
| 1098 /** | |
| 1099 * Returns a well-formed language tag for this locale ID. | |
| 1100 * <p> | |
| 1101 * <b>Note</b>: When <code>strict</code> is FALSE, any locale | |
| 1102 * fields which do not satisfy the BCP47 syntax requirement will | |
| 1103 * be omitted from the result. When <code>strict</code> is | |
| 1104 * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the | |
| 1105 * <code>err</code> if any locale fields do not satisfy the | |
| 1106 * BCP47 syntax requirement. | |
| 1107 * @param localeID the input lcoale ID | |
| 1108 * @param langtag the output buffer receiving BCP47 language | |
| 1109 * tag for the locale ID. | |
| 1110 * @param langtagCapacity the size of the BCP47 language tag | |
| 1111 * output buffer. | |
| 1112 * @param strict boolean value indicating if the function returns | |
| 1113 * an error for an ill-formed input locale ID. | |
| 1114 * @param err error information if receiving the language | |
| 1115 * tag failed. | |
| 1116 * @return The length of the BCP47 language tag. | |
| 1117 * @draft ICU 4.2 | |
| 1118 */ | |
| 1119 U_DRAFT int32_t U_EXPORT2 | |
| 1120 uloc_toLanguageTag(const char* localeID, | |
| 1121 char* langtag, | |
| 1122 int32_t langtagCapacity, | |
| 1123 UBool strict, | |
| 1124 UErrorCode* err); | |
| 1125 | |
| 1126 #endif /*_ULOC*/ | |
| OLD | NEW |