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