• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 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
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 additonal <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 additonal 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 serivce 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 
348 #ifndef U_HIDE_DEPRECATED_API
349   /** This is the requested locale
350    *  @deprecated ICU 2.8
351    */
352   ULOC_REQUESTED_LOCALE = 2,
353 
354     /**
355      * One more than the highest normal ULocDataLocaleType value.
356      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
357      */
358     ULOC_DATA_LOCALE_TYPE_LIMIT = 3
359 #endif  // U_HIDE_DEPRECATED_API
360 } ULocDataLocaleType;
361 
362 #ifndef U_HIDE_SYSTEM_API
363 /**
364  * Gets ICU's default locale.
365  * The returned string is a snapshot in time, and will remain valid
366  *   and unchanged even when uloc_setDefault() is called.
367  *   The returned storage is owned by ICU, and must not be altered or deleted
368  *   by the caller.
369  *
370  * @return the ICU default locale
371  * @system
372  * @stable ICU 2.0
373  */
374 U_STABLE const char* U_EXPORT2
375 uloc_getDefault(void);
376 
377 /**
378  * Sets ICU's default locale.
379  *    By default (without calling this function), ICU's default locale will be based
380  *    on information obtained from the underlying system environment.
381  *    <p>
382  *    Changes to ICU's default locale do not propagate back to the
383  *    system environment.
384  *    <p>
385  *    Changes to ICU's default locale to not affect any ICU services that
386  *    may already be open based on the previous default locale value.
387  *
388  * @param localeID the new ICU default locale. A value of NULL will try to get
389  *                 the system's default locale.
390  * @param status the error information if the setting of default locale fails
391  * @system
392  * @stable ICU 2.0
393  */
394 U_STABLE void U_EXPORT2
395 uloc_setDefault(const char* localeID,
396         UErrorCode*       status);
397 #endif  /* U_HIDE_SYSTEM_API */
398 
399 /**
400  * Gets the language code for the specified locale.
401  *
402  * @param localeID the locale to get the ISO language code with
403  * @param language the language code for localeID
404  * @param languageCapacity the size of the language buffer to store the
405  * language code with
406  * @param err error information if retrieving the language code failed
407  * @return the actual buffer size needed for the language code.  If it's greater
408  * than languageCapacity, the returned language code will be truncated.
409  * @stable ICU 2.0
410  */
411 U_STABLE int32_t U_EXPORT2
412 uloc_getLanguage(const char*    localeID,
413          char* language,
414          int32_t languageCapacity,
415          UErrorCode* err);
416 
417 /**
418  * Gets the script code for the specified locale.
419  *
420  * @param localeID the locale to get the ISO language code with
421  * @param script the language code for localeID
422  * @param scriptCapacity the size of the language buffer to store the
423  * language code with
424  * @param err error information if retrieving the language code failed
425  * @return the actual buffer size needed for the language code.  If it's greater
426  * than scriptCapacity, the returned language code will be truncated.
427  * @stable ICU 2.8
428  */
429 U_STABLE int32_t U_EXPORT2
430 uloc_getScript(const char*    localeID,
431          char* script,
432          int32_t scriptCapacity,
433          UErrorCode* err);
434 
435 /**
436  * Gets the  country code for the specified locale.
437  *
438  * @param localeID the locale to get the country code with
439  * @param country the country code for localeID
440  * @param countryCapacity the size of the country buffer to store the
441  * country code with
442  * @param err error information if retrieving the country code failed
443  * @return the actual buffer size needed for the country code.  If it's greater
444  * than countryCapacity, the returned country code will be truncated.
445  * @stable ICU 2.0
446  */
447 U_STABLE int32_t U_EXPORT2
448 uloc_getCountry(const char*    localeID,
449         char* country,
450         int32_t countryCapacity,
451         UErrorCode* err);
452 
453 /**
454  * Gets the variant code for the specified locale.
455  *
456  * @param localeID the locale to get the variant code with
457  * @param variant the variant code for localeID
458  * @param variantCapacity the size of the variant buffer to store the
459  * variant code with
460  * @param err error information if retrieving the variant code failed
461  * @return the actual buffer size needed for the variant code.  If it's greater
462  * than variantCapacity, the returned variant code will be truncated.
463  * @stable ICU 2.0
464  */
465 U_STABLE int32_t U_EXPORT2
466 uloc_getVariant(const char*    localeID,
467         char* variant,
468         int32_t variantCapacity,
469         UErrorCode* err);
470 
471 
472 /**
473  * Gets the full name for the specified locale.
474  * Note: This has the effect of 'canonicalizing' the ICU locale ID to
475  * a certain extent. Upper and lower case are set as needed.
476  * It does NOT map aliased names in any way.
477  * See the top of this header file.
478  * This API supports preflighting.
479  *
480  * @param localeID the locale to get the full name with
481  * @param name fill in buffer for the name without keywords.
482  * @param nameCapacity capacity of the fill in buffer.
483  * @param err error information if retrieving the full name failed
484  * @return the actual buffer size needed for the full name.  If it's greater
485  * than nameCapacity, the returned full name will be truncated.
486  * @stable ICU 2.0
487  */
488 U_STABLE int32_t U_EXPORT2
489 uloc_getName(const char*    localeID,
490          char* name,
491          int32_t nameCapacity,
492          UErrorCode* err);
493 
494 /**
495  * Gets the full name for the specified locale.
496  * Note: This has the effect of 'canonicalizing' the string to
497  * a certain extent. Upper and lower case are set as needed,
498  * and if the components were in 'POSIX' format they are changed to
499  * ICU format.  It does NOT map aliased names in any way.
500  * See the top of this header file.
501  *
502  * @param localeID the locale to get the full name with
503  * @param name the full name for localeID
504  * @param nameCapacity the size of the name buffer to store the
505  * full name with
506  * @param err error information if retrieving the full name failed
507  * @return the actual buffer size needed for the full name.  If it's greater
508  * than nameCapacity, the returned full name will be truncated.
509  * @stable ICU 2.8
510  */
511 U_STABLE int32_t U_EXPORT2
512 uloc_canonicalize(const char*    localeID,
513          char* name,
514          int32_t nameCapacity,
515          UErrorCode* err);
516 
517 /**
518  * Gets the ISO language code for the specified locale.
519  *
520  * @param localeID the locale to get the ISO language code with
521  * @return language the ISO language code for localeID
522  * @stable ICU 2.0
523  */
524 U_STABLE const char* U_EXPORT2
525 uloc_getISO3Language(const char* localeID);
526 
527 
528 /**
529  * Gets the ISO country code for the specified locale.
530  *
531  * @param localeID the locale to get the ISO country code with
532  * @return country the ISO country code for localeID
533  * @stable ICU 2.0
534  */
535 U_STABLE const char* U_EXPORT2
536 uloc_getISO3Country(const char* localeID);
537 
538 /**
539  * Gets the Win32 LCID value for the specified locale.
540  * If the ICU locale is not recognized by Windows, 0 will be returned.
541  *
542  * @param localeID the locale to get the Win32 LCID value with
543  * @return country the Win32 LCID for localeID
544  * @stable ICU 2.0
545  */
546 U_STABLE uint32_t U_EXPORT2
547 uloc_getLCID(const char* localeID);
548 
549 /**
550  * Gets the language name suitable for display for the specified locale.
551  *
552  * @param locale the locale to get the ISO language code with
553  * @param displayLocale Specifies the locale to be used to display the name.  In other words,
554  *                 if the locale's language code is "en", passing Locale::getFrench() for
555  *                 inLocale would result in "Anglais", while passing Locale::getGerman()
556  *                 for inLocale would result in "Englisch".
557  * @param language the displayable language code for localeID
558  * @param languageCapacity the size of the language buffer to store the
559  * displayable language code with
560  * @param status error information if retrieving the displayable language code failed
561  * @return the actual buffer size needed for the displayable language code.  If it's greater
562  * than languageCapacity, the returned language code will be truncated.
563  * @stable ICU 2.0
564  */
565 U_STABLE int32_t U_EXPORT2
566 uloc_getDisplayLanguage(const char* locale,
567             const char* displayLocale,
568             UChar* language,
569             int32_t languageCapacity,
570             UErrorCode* status);
571 
572 /**
573  * Gets the script name suitable for display for the specified locale.
574  *
575  * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
576  * @param displayLocale Specifies the locale to be used to display the name.  In other words,
577  *                 if the locale's language code is "en", passing Locale::getFrench() for
578  *                 inLocale would result in "", while passing Locale::getGerman()
579  *                 for inLocale would result in "". NULL may be used to specify the default.
580  * @param script the displayable country code for localeID
581  * @param scriptCapacity the size of the script buffer to store the
582  * displayable script code with
583  * @param status error information if retrieving the displayable script code failed
584  * @return the actual buffer size needed for the displayable script code.  If it's greater
585  * than scriptCapacity, the returned displayable script code will be truncated.
586  * @stable ICU 2.8
587  */
588 U_STABLE int32_t U_EXPORT2
589 uloc_getDisplayScript(const char* locale,
590             const char* displayLocale,
591             UChar* script,
592             int32_t scriptCapacity,
593             UErrorCode* status);
594 
595 /**
596  * Gets the country name suitable for display for the specified locale.
597  * Warning: this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
598  * To get the display name for a region alone, or for other options, use ULocaleDisplayNames instead.
599  *
600  * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
601  * @param displayLocale Specifies the locale to be used to display the name.  In other words,
602  *                 if the locale's language code is "en", passing Locale::getFrench() for
603  *                 inLocale would result in "Anglais", while passing Locale::getGerman()
604  *                 for inLocale would result in "Englisch". NULL may be used to specify the default.
605  * @param country the displayable country code for localeID
606  * @param countryCapacity the size of the country buffer to store the
607  * displayable country code with
608  * @param status error information if retrieving the displayable country code failed
609  * @return the actual buffer size needed for the displayable country code.  If it's greater
610  * than countryCapacity, the returned displayable country code will be truncated.
611  * @stable ICU 2.0
612  */
613 U_STABLE int32_t U_EXPORT2
614 uloc_getDisplayCountry(const char* locale,
615                        const char* displayLocale,
616                        UChar* country,
617                        int32_t countryCapacity,
618                        UErrorCode* status);
619 
620 
621 /**
622  * Gets the variant name suitable for display for the specified locale.
623  *
624  * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
625  * @param displayLocale Specifies the locale to be used to display the name.  In other words,
626  *                 if the locale's language code is "en", passing Locale::getFrench() for
627  *                 inLocale would result in "Anglais", while passing Locale::getGerman()
628  *                 for inLocale would result in "Englisch". NULL may be used to specify the default.
629  * @param variant the displayable variant code for localeID
630  * @param variantCapacity the size of the variant buffer to store the
631  * displayable variant code with
632  * @param status error information if retrieving the displayable variant code failed
633  * @return the actual buffer size needed for the displayable variant code.  If it's greater
634  * than variantCapacity, the returned displayable variant code will be truncated.
635  * @stable ICU 2.0
636  */
637 U_STABLE int32_t U_EXPORT2
638 uloc_getDisplayVariant(const char* locale,
639                        const char* displayLocale,
640                        UChar* variant,
641                        int32_t variantCapacity,
642                        UErrorCode* status);
643 
644 /**
645  * Gets the keyword name suitable for display for the specified locale.
646  * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
647  * string for the keyword collation.
648  * Usage:
649  * <code>
650  *    UErrorCode status = U_ZERO_ERROR;
651  *    const char* keyword =NULL;
652  *    int32_t keywordLen = 0;
653  *    int32_t keywordCount = 0;
654  *    UChar displayKeyword[256];
655  *    int32_t displayKeywordLen = 0;
656  *    UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status);
657  *    for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){
658  *          if(U_FAILURE(status)){
659  *              ...something went wrong so handle the error...
660  *              break;
661  *          }
662  *          // the uenum_next returns NUL terminated string
663  *          keyword = uenum_next(keywordEnum, &keywordLen, &status);
664  *          displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256);
665  *          ... do something interesting .....
666  *    }
667  *    uenum_close(keywordEnum);
668  * </code>
669  * @param keyword           The keyword whose display string needs to be returned.
670  * @param displayLocale     Specifies the locale to be used to display the name.  In other words,
671  *                          if the locale's language code is "en", passing Locale::getFrench() for
672  *                          inLocale would result in "Anglais", while passing Locale::getGerman()
673  *                          for inLocale would result in "Englisch". NULL may be used to specify the default.
674  * @param dest              the buffer to which the displayable keyword should be written.
675  * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then
676  *                          dest may be NULL and the function will only return the length of the
677  *                          result without writing any of the result string (pre-flighting).
678  * @param status            error information if retrieving the displayable string failed.
679  *                          Should not be NULL and should not indicate failure on entry.
680  * @return the actual buffer size needed for the displayable variant code.
681  * @see #uloc_openKeywords
682  * @stable ICU 2.8
683  */
684 U_STABLE int32_t U_EXPORT2
685 uloc_getDisplayKeyword(const char* keyword,
686                        const char* displayLocale,
687                        UChar* dest,
688                        int32_t destCapacity,
689                        UErrorCode* status);
690 /**
691  * Gets the value of the keyword suitable for display for the specified locale.
692  * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
693  * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword.
694  *
695  * @param locale            The locale to get the displayable variant code with. NULL may be used to specify the default.
696  * @param keyword           The keyword for whose value should be used.
697  * @param displayLocale     Specifies the locale to be used to display the name.  In other words,
698  *                          if the locale's language code is "en", passing Locale::getFrench() for
699  *                          inLocale would result in "Anglais", while passing Locale::getGerman()
700  *                          for inLocale would result in "Englisch". NULL may be used to specify the default.
701  * @param dest              the buffer to which the displayable keyword should be written.
702  * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then
703  *                          dest may be NULL and the function will only return the length of the
704  *                          result without writing any of the result string (pre-flighting).
705  * @param status            error information if retrieving the displayable string failed.
706  *                          Should not be NULL and must not indicate failure on entry.
707  * @return the actual buffer size needed for the displayable variant code.
708  * @stable ICU 2.8
709  */
710 U_STABLE int32_t U_EXPORT2
711 uloc_getDisplayKeywordValue(   const char* locale,
712                                const char* keyword,
713                                const char* displayLocale,
714                                UChar* dest,
715                                int32_t destCapacity,
716                                UErrorCode* status);
717 /**
718  * Gets the full name suitable for display for the specified locale.
719  *
720  * @param localeID the locale to get the displayable name with. NULL may be used to specify the default.
721  * @param inLocaleID Specifies the locale to be used to display the name.  In other words,
722  *                   if the locale's language code is "en", passing Locale::getFrench() for
723  *                   inLocale would result in "Anglais", while passing Locale::getGerman()
724  *                   for inLocale would result in "Englisch". NULL may be used to specify the default.
725  * @param result the displayable name for localeID
726  * @param maxResultSize the size of the name buffer to store the
727  * displayable full name with
728  * @param err error information if retrieving the displayable name failed
729  * @return the actual buffer size needed for the displayable name.  If it's greater
730  * than maxResultSize, the returned displayable name will be truncated.
731  * @stable ICU 2.0
732  */
733 U_STABLE int32_t U_EXPORT2
734 uloc_getDisplayName(const char* localeID,
735             const char* inLocaleID,
736             UChar* result,
737             int32_t maxResultSize,
738             UErrorCode* err);
739 
740 
741 /**
742  * Gets the specified locale from a list of all available locales.
743  * The return value is a pointer to an item of
744  * a locale name array.  Both this array and the pointers
745  * it contains are owned by ICU and should not be deleted or written through
746  * by the caller.  The locale name is terminated by a null pointer.
747  * @param n the specific locale name index of the available locale list
748  * @return a specified locale name of all available locales
749  * @stable ICU 2.0
750  */
751 U_STABLE const char* U_EXPORT2
752 uloc_getAvailable(int32_t n);
753 
754 /**
755  * Gets the size of the all available locale list.
756  *
757  * @return the size of the locale list
758  * @stable ICU 2.0
759  */
760 U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
761 
762 /**
763  *
764  * Gets a list of all available 2-letter language codes defined in ISO 639,
765  * plus additional 3-letter codes determined to be useful for locale generation as
766  * defined by Unicode CLDR. This is a pointer
767  * to an array of pointers to arrays of char.  All of these pointers are owned
768  * by ICU-- do not delete them, and do not write through them.  The array is
769  * terminated with a null pointer.
770  * @return a list of all available language codes
771  * @stable ICU 2.0
772  */
773 U_STABLE const char* const* U_EXPORT2
774 uloc_getISOLanguages(void);
775 
776 /**
777  *
778  * Gets a list of all available 2-letter country codes defined in ISO 639.  This is a
779  * pointer to an array of pointers to arrays of char.  All of these pointers are
780  * owned by ICU-- do not delete them, and do not write through them.  The array is
781  * terminated with a null pointer.
782  * @return a list of all available country codes
783  * @stable ICU 2.0
784  */
785 U_STABLE const char* const* U_EXPORT2
786 uloc_getISOCountries(void);
787 
788 /**
789  * Truncate the locale ID string to get the parent locale ID.
790  * Copies the part of the string before the last underscore.
791  * The parent locale ID will be an empty string if there is no
792  * underscore, or if there is only one underscore at localeID[0].
793  *
794  * @param localeID Input locale ID string.
795  * @param parent   Output string buffer for the parent locale ID.
796  * @param parentCapacity Size of the output buffer.
797  * @param err A UErrorCode value.
798  * @return The length of the parent locale ID.
799  * @stable ICU 2.0
800  */
801 U_STABLE int32_t U_EXPORT2
802 uloc_getParent(const char*    localeID,
803                  char* parent,
804                  int32_t parentCapacity,
805                  UErrorCode* err);
806 
807 
808 
809 
810 /**
811  * Gets the full name for the specified locale, like uloc_getName(),
812  * but without keywords.
813  *
814  * Note: This has the effect of 'canonicalizing' the string to
815  * a certain extent. Upper and lower case are set as needed,
816  * and if the components were in 'POSIX' format they are changed to
817  * ICU format.  It does NOT map aliased names in any way.
818  * See the top of this header file.
819  *
820  * This API strips off the keyword part, so "de_DE\@collation=phonebook"
821  * will become "de_DE".
822  * This API supports preflighting.
823  *
824  * @param localeID the locale to get the full name with
825  * @param name fill in buffer for the name without keywords.
826  * @param nameCapacity capacity of the fill in buffer.
827  * @param err error information if retrieving the full name failed
828  * @return the actual buffer size needed for the full name.  If it's greater
829  * than nameCapacity, the returned full name will be truncated.
830  * @stable ICU 2.8
831  */
832 U_STABLE int32_t U_EXPORT2
833 uloc_getBaseName(const char*    localeID,
834          char* name,
835          int32_t nameCapacity,
836          UErrorCode* err);
837 
838 /**
839  * Gets an enumeration of keywords for the specified locale. Enumeration
840  * must get disposed of by the client using uenum_close function.
841  *
842  * @param localeID the locale to get the variant code with
843  * @param status error information if retrieving the keywords failed
844  * @return enumeration of keywords or NULL if there are no keywords.
845  * @stable ICU 2.8
846  */
847 U_STABLE UEnumeration* U_EXPORT2
848 uloc_openKeywords(const char* localeID,
849                         UErrorCode* status);
850 
851 /**
852  * Get the value for a keyword. Locale name does not need to be normalized.
853  *
854  * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK")
855  * @param keywordName name of the keyword for which we want the value. Case insensitive.
856  * @param buffer receiving buffer
857  * @param bufferCapacity capacity of receiving buffer
858  * @param status containing error code - buffer not big enough.
859  * @return the length of keyword value
860  * @stable ICU 2.8
861  */
862 U_STABLE int32_t U_EXPORT2
863 uloc_getKeywordValue(const char* localeID,
864                      const char* keywordName,
865                      char* buffer, int32_t bufferCapacity,
866                      UErrorCode* status);
867 
868 
869 /**
870  * Sets or removes the value of the specified keyword.
871  *
872  * For removing all keywords, use uloc_getBaseName().
873  *
874  * NOTE: Unlike almost every other ICU function which takes a
875  * buffer, this function will NOT truncate the output text. If a
876  * BUFFER_OVERFLOW_ERROR is received, it means that the original
877  * buffer is untouched. This is done to prevent incorrect or possibly
878  * even malformed locales from being generated and used.
879  *
880  * @param keywordName name of the keyword to be set. Case insensitive.
881  * @param keywordValue value of the keyword to be set. If 0-length or
882  *  NULL, will result in the keyword being removed. No error is given if
883  *  that keyword does not exist.
884  * @param buffer input buffer containing locale to be modified.
885  * @param bufferCapacity capacity of receiving buffer
886  * @param status containing error code - buffer not big enough.
887  * @return the length needed for the buffer
888  * @see uloc_getKeywordValue
889  * @stable ICU 3.2
890  */
891 U_STABLE int32_t U_EXPORT2
892 uloc_setKeywordValue(const char* keywordName,
893                      const char* keywordValue,
894                      char* buffer, int32_t bufferCapacity,
895                      UErrorCode* status);
896 
897 /**
898  * Returns whether the locale's script is written right-to-left.
899  * If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
900  * If no likely script is known, then FALSE is returned.
901  *
902  * A script is right-to-left according to the CLDR script metadata
903  * which corresponds to whether the script's letters have Bidi_Class=R or AL.
904  *
905  * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
906  *
907  * @param locale input locale ID
908  * @return TRUE if the locale's script is written right-to-left
909  * @stable ICU 54
910  */
911 U_STABLE UBool U_EXPORT2
912 uloc_isRightToLeft(const char *locale);
913 
914 /**
915  * enums for the  return value for the character and line orientation
916  * functions.
917  * @stable ICU 4.0
918  */
919 typedef enum {
920   ULOC_LAYOUT_LTR   = 0,  /* left-to-right. */
921   ULOC_LAYOUT_RTL    = 1,  /* right-to-left. */
922   ULOC_LAYOUT_TTB    = 2,  /* top-to-bottom. */
923   ULOC_LAYOUT_BTT    = 3,   /* bottom-to-top. */
924   ULOC_LAYOUT_UNKNOWN
925 } ULayoutType;
926 
927 /**
928  * Get the layout character orientation for the specified locale.
929  *
930  * @param localeId locale name
931  * @param status Error status
932  * @return an enum indicating the layout orientation for characters.
933  * @stable ICU 4.0
934  */
935 U_STABLE ULayoutType U_EXPORT2
936 uloc_getCharacterOrientation(const char* localeId,
937                              UErrorCode *status);
938 
939 /**
940  * Get the layout line orientation for the specified locale.
941  *
942  * @param localeId locale name
943  * @param status Error status
944  * @return an enum indicating the layout orientation for lines.
945  * @stable ICU 4.0
946  */
947 U_STABLE ULayoutType U_EXPORT2
948 uloc_getLineOrientation(const char* localeId,
949                         UErrorCode *status);
950 
951 /**
952  * enums for the 'outResult' parameter return value
953  * @see uloc_acceptLanguageFromHTTP
954  * @see uloc_acceptLanguage
955  * @stable ICU 3.2
956  */
957 typedef enum {
958   ULOC_ACCEPT_FAILED   = 0,  /* No exact match was found. */
959   ULOC_ACCEPT_VALID    = 1,  /* An exact match was found. */
960   ULOC_ACCEPT_FALLBACK = 2   /* A fallback was found, for example,
961                                 Accept list contained 'ja_JP'
962                                 which matched available locale 'ja'. */
963 } UAcceptResult;
964 
965 
966 /**
967  * Based on a HTTP header from a web browser and a list of available locales,
968  * determine an acceptable locale for the user.
969  * @param result - buffer to accept the result locale
970  * @param resultAvailable the size of the result buffer.
971  * @param outResult - An out parameter that contains the fallback status
972  * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP.
973  * @param availableLocales - list of available locales to match
974  * @param status Error status, may be BUFFER_OVERFLOW_ERROR
975  * @return length needed for the locale.
976  * @stable ICU 3.2
977  */
978 U_STABLE int32_t U_EXPORT2
979 uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
980                             UAcceptResult *outResult,
981                             const char *httpAcceptLanguage,
982                             UEnumeration* availableLocales,
983                             UErrorCode *status);
984 
985 /**
986  * Based on a list of available locales,
987  * determine an acceptable locale for the user.
988  * @param result - buffer to accept the result locale
989  * @param resultAvailable the size of the result buffer.
990  * @param outResult - An out parameter that contains the fallback status
991  * @param acceptList - list of acceptable languages
992  * @param acceptListCount - count of acceptList items
993  * @param availableLocales - list of available locales to match
994  * @param status Error status, may be BUFFER_OVERFLOW_ERROR
995  * @return length needed for the locale.
996  * @stable ICU 3.2
997  */
998 U_STABLE int32_t U_EXPORT2
999 uloc_acceptLanguage(char *result, int32_t resultAvailable,
1000                     UAcceptResult *outResult, const char **acceptList,
1001                     int32_t acceptListCount,
1002                     UEnumeration* availableLocales,
1003                     UErrorCode *status);
1004 
1005 
1006 /**
1007  * Gets the ICU locale ID for the specified Win32 LCID value.
1008  *
1009  * @param hostID the Win32 LCID to translate
1010  * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated
1011  *  if there is room.
1012  * @param localeCapacity the size of the output buffer
1013  * @param status an error is returned if the LCID is unrecognized or the output buffer
1014  *  is too small
1015  * @return actual the actual size of the locale ID, not including NUL-termination
1016  * @stable ICU 3.8
1017  */
1018 U_STABLE int32_t U_EXPORT2
1019 uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
1020                     UErrorCode *status);
1021 
1022 
1023 /**
1024  * Add the likely subtags for a provided locale ID, per the algorithm described
1025  * in the following CLDR technical report:
1026  *
1027  *   http://www.unicode.org/reports/tr35/#Likely_Subtags
1028  *
1029  * If localeID is already in the maximal form, or there is no data available
1030  * for maximization, it will be copied to the output buffer.  For example,
1031  * "und-Zzzz" cannot be maximized, since there is no reasonable maximization.
1032  *
1033  * Examples:
1034  *
1035  * "en" maximizes to "en_Latn_US"
1036  *
1037  * "de" maximizes to "de_Latn_US"
1038  *
1039  * "sr" maximizes to "sr_Cyrl_RS"
1040  *
1041  * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
1042  *
1043  * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
1044  *
1045  * @param localeID The locale to maximize
1046  * @param maximizedLocaleID The maximized locale
1047  * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer
1048  * @param err Error information if maximizing the locale failed.  If the length
1049  * of the localeID and the null-terminator is greater than the maximum allowed size,
1050  * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
1051  * @return The actual buffer size needed for the maximized locale.  If it's
1052  * greater than maximizedLocaleIDCapacity, the returned ID will be truncated.
1053  * On error, the return value is -1.
1054  * @stable ICU 4.0
1055  */
1056 U_STABLE int32_t U_EXPORT2
1057 uloc_addLikelySubtags(const char*    localeID,
1058          char* maximizedLocaleID,
1059          int32_t maximizedLocaleIDCapacity,
1060          UErrorCode* err);
1061 
1062 
1063 /**
1064  * Minimize the subtags for a provided locale ID, per the algorithm described
1065  * in the following CLDR technical report:
1066  *
1067  *   http://www.unicode.org/reports/tr35/#Likely_Subtags
1068  *
1069  * If localeID is already in the minimal form, or there is no data available
1070  * for minimization, it will be copied to the output buffer.  Since the
1071  * minimization algorithm relies on proper maximization, see the comments
1072  * for uloc_addLikelySubtags for reasons why there might not be any data.
1073  *
1074  * Examples:
1075  *
1076  * "en_Latn_US" minimizes to "en"
1077  *
1078  * "de_Latn_US" minimizes to "de"
1079  *
1080  * "sr_Cyrl_RS" minimizes to "sr"
1081  *
1082  * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
1083  * script, and minimizing to "zh" would imply "zh_Hans_CN".)
1084  *
1085  * @param localeID The locale to minimize
1086  * @param minimizedLocaleID The minimized locale
1087  * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer
1088  * @param err Error information if minimizing the locale failed.  If the length
1089  * of the localeID and the null-terminator is greater than the maximum allowed size,
1090  * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
1091  * @return The actual buffer size needed for the minimized locale.  If it's
1092  * greater than minimizedLocaleIDCapacity, the returned ID will be truncated.
1093  * On error, the return value is -1.
1094  * @stable ICU 4.0
1095  */
1096 U_STABLE int32_t U_EXPORT2
1097 uloc_minimizeSubtags(const char*    localeID,
1098          char* minimizedLocaleID,
1099          int32_t minimizedLocaleIDCapacity,
1100          UErrorCode* err);
1101 
1102 /**
1103  * Returns a locale ID for the specified BCP47 language tag string.
1104  * If the specified language tag contains any ill-formed subtags,
1105  * the first such subtag and all following subtags are ignored.
1106  * <p>
1107  * This implements the 'Language-Tag' production of BCP47, and so
1108  * supports grandfathered (regular and irregular) as well as private
1109  * use language tags.  Private use tags are represented as 'x-whatever',
1110  * and grandfathered tags are converted to their canonical replacements
1111  * where they exist.  Note that a few grandfathered tags have no modern
1112  * replacement, these will be converted using the fallback described in
1113  * the first paragraph, so some information might be lost.
1114  * @param langtag   the input BCP47 language tag.
1115  * @param localeID  the output buffer receiving a locale ID for the
1116  *                  specified BCP47 language tag.
1117  * @param localeIDCapacity  the size of the locale ID output buffer.
1118  * @param parsedLength  if not NULL, successfully parsed length
1119  *                      for the input language tag is set.
1120  * @param err       error information if receiving the locald ID
1121  *                  failed.
1122  * @return          the length of the locale ID.
1123  * @stable ICU 4.2
1124  */
1125 U_STABLE int32_t U_EXPORT2
1126 uloc_forLanguageTag(const char* langtag,
1127                     char* localeID,
1128                     int32_t localeIDCapacity,
1129                     int32_t* parsedLength,
1130                     UErrorCode* err);
1131 
1132 /**
1133  * Returns a well-formed language tag for this locale ID.
1134  * <p>
1135  * <b>Note</b>: When <code>strict</code> is FALSE, any locale
1136  * fields which do not satisfy the BCP47 syntax requirement will
1137  * be omitted from the result.  When <code>strict</code> is
1138  * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
1139  * <code>err</code> if any locale fields do not satisfy the
1140  * BCP47 syntax requirement.
1141  * @param localeID  the input locale ID
1142  * @param langtag   the output buffer receiving BCP47 language
1143  *                  tag for the locale ID.
1144  * @param langtagCapacity   the size of the BCP47 language tag
1145  *                          output buffer.
1146  * @param strict    boolean value indicating if the function returns
1147  *                  an error for an ill-formed input locale ID.
1148  * @param err       error information if receiving the language
1149  *                  tag failed.
1150  * @return          The length of the BCP47 language tag.
1151  * @stable ICU 4.2
1152  */
1153 U_STABLE int32_t U_EXPORT2
1154 uloc_toLanguageTag(const char* localeID,
1155                    char* langtag,
1156                    int32_t langtagCapacity,
1157                    UBool strict,
1158                    UErrorCode* err);
1159 
1160 /**
1161  * Converts the specified keyword (legacy key, or BCP 47 Unicode locale
1162  * extension key) to the equivalent BCP 47 Unicode locale extension key.
1163  * For example, BCP 47 Unicode locale extension key "co" is returned for
1164  * the input keyword "collation".
1165  * <p>
1166  * When the specified keyword is unknown, but satisfies the BCP syntax,
1167  * then the pointer to the input keyword itself will be returned.
1168  * For example,
1169  * <code>uloc_toUnicodeLocaleKey("ZZ")</code> returns "ZZ".
1170  *
1171  * @param keyword       the input locale keyword (either legacy key
1172  *                      such as "collation" or BCP 47 Unicode locale extension
1173  *                      key such as "co").
1174  * @return              the well-formed BCP 47 Unicode locale extension key,
1175  *                      or NULL if the specified locale keyword cannot be
1176  *                      mapped to a well-formed BCP 47 Unicode locale extension
1177  *                      key.
1178  * @see uloc_toLegacyKey
1179  * @stable ICU 54
1180  */
1181 U_STABLE const char* U_EXPORT2
1182 uloc_toUnicodeLocaleKey(const char* keyword);
1183 
1184 /**
1185  * Converts the specified keyword value (legacy type, or BCP 47
1186  * Unicode locale extension type) to the well-formed BCP 47 Unicode locale
1187  * extension type for the specified keyword (category). For example, BCP 47
1188  * Unicode locale extension type "phonebk" is returned for the input
1189  * keyword value "phonebook", with the keyword "collation" (or "co").
1190  * <p>
1191  * When the specified keyword is not recognized, but the specified value
1192  * satisfies the syntax of the BCP 47 Unicode locale extension type,
1193  * or when the specified keyword allows 'variable' type and the specified
1194  * value satisfies the syntax,  then the pointer to the input type value itself
1195  * will be returned.
1196  * For example,
1197  * <code>uloc_toUnicodeLocaleType("Foo", "Bar")</code> returns "Bar",
1198  * <code>uloc_toUnicodeLocaleType("variableTop", "00A4")</code> returns "00A4".
1199  *
1200  * @param keyword       the locale keyword (either legacy key such as
1201  *                      "collation" or BCP 47 Unicode locale extension
1202  *                      key such as "co").
1203  * @param value         the locale keyword value (either legacy type
1204  *                      such as "phonebook" or BCP 47 Unicode locale extension
1205  *                      type such as "phonebk").
1206  * @return              the well-formed BCP47 Unicode locale extension type,
1207  *                      or NULL if the locale keyword value cannot be mapped to
1208  *                      a well-formed BCP 47 Unicode locale extension type.
1209  * @see uloc_toLegacyType
1210  * @stable ICU 54
1211  */
1212 U_STABLE const char* U_EXPORT2
1213 uloc_toUnicodeLocaleType(const char* keyword, const char* value);
1214 
1215 /**
1216  * Converts the specified keyword (BCP 47 Unicode locale extension key, or
1217  * legacy key) to the legacy key. For example, legacy key "collation" is
1218  * returned for the input BCP 47 Unicode locale extension key "co".
1219  *
1220  * @param keyword       the input locale keyword (either BCP 47 Unicode locale
1221  *                      extension key or legacy key).
1222  * @return              the well-formed legacy key, or NULL if the specified
1223  *                      keyword cannot be mapped to a well-formed legacy key.
1224  * @see toUnicodeLocaleKey
1225  * @stable ICU 54
1226  */
1227 U_STABLE const char* U_EXPORT2
1228 uloc_toLegacyKey(const char* keyword);
1229 
1230 /**
1231  * Converts the specified keyword value (BCP 47 Unicode locale extension type,
1232  * or legacy type or type alias) to the canonical legacy type. For example,
1233  * the legacy type "phonebook" is returned for the input BCP 47 Unicode
1234  * locale extension type "phonebk" with the keyword "collation" (or "co").
1235  * <p>
1236  * When the specified keyword is not recognized, but the specified value
1237  * satisfies the syntax of legacy key, or when the specified keyword
1238  * allows 'variable' type and the specified value satisfies the syntax,
1239  * then the pointer to the input type value itself will be returned.
1240  * For example,
1241  * <code>uloc_toLegacyType("Foo", "Bar")</code> returns "Bar",
1242  * <code>uloc_toLegacyType("vt", "00A4")</code> returns "00A4".
1243  *
1244  * @param keyword       the locale keyword (either legacy keyword such as
1245  *                      "collation" or BCP 47 Unicode locale extension
1246  *                      key such as "co").
1247  * @param value         the locale keyword value (either BCP 47 Unicode locale
1248  *                      extension type such as "phonebk" or legacy keyword value
1249  *                      such as "phonebook").
1250  * @return              the well-formed legacy type, or NULL if the specified
1251  *                      keyword value cannot be mapped to a well-formed legacy
1252  *                      type.
1253  * @see toUnicodeLocaleType
1254  * @stable ICU 54
1255  */
1256 U_STABLE const char* U_EXPORT2
1257 uloc_toLegacyType(const char* keyword, const char* value);
1258 
1259 #endif /*_ULOC*/
1260