annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/uloc.h @ 69:33d812a61356

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