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