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