Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes16kdownloads
uloc.h1366 linesDownload Raw Back to unicode
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 
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 */
338typedef 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 */
374U_STABLE const char* U_EXPORT2
375uloc_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 */
394U_STABLE void U_EXPORT2
395uloc_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 */
411U_STABLE int32_t U_EXPORT2
412uloc_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 */
429U_STABLE int32_t U_EXPORT2
430uloc_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 */
447U_STABLE int32_t U_EXPORT2
448uloc_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 */
465U_STABLE int32_t U_EXPORT2
466uloc_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 */
488U_STABLE int32_t U_EXPORT2
489uloc_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 */
511U_STABLE int32_t U_EXPORT2
512uloc_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 */
524U_STABLE const char* U_EXPORT2
525uloc_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 */
535U_STABLE const char* U_EXPORT2
536uloc_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 * LCIDs were deprecated with Windows Vista and Microsoft recommends
543 * that developers use BCP47 style tags instead (uloc_toLanguageTag).
544 *
545 * @param localeID the locale to get the Win32 LCID value with
546 * @return country the Win32 LCID for localeID
547 * @stable ICU 2.0
548 */
549U_STABLE uint32_t U_EXPORT2
550uloc_getLCID(const char* localeID);
551
552/**
553 * Gets the language name suitable for display for the specified locale.
554 *
555 * @param locale the locale to get the ISO language code with
556 * @param displayLocale Specifies the locale to be used to display the name.  In other words,
557 *                 if the locale's language code is "en", passing Locale::getFrench() for
558 *                 inLocale would result in "Anglais", while passing Locale::getGerman()
559 *                 for inLocale would result in "Englisch".
560 * @param language the displayable language code for localeID
561 * @param languageCapacity the size of the language buffer to store the  
562 * displayable language code with
563 * @param status error information if retrieving the displayable language code failed
564 * @return the actual buffer size needed for the displayable language code.  If it's greater 
565 * than languageCapacity, the returned language code will be truncated.  
566 * @stable ICU 2.0
567 */
568U_STABLE int32_t U_EXPORT2
569uloc_getDisplayLanguage(const char* locale,
570            const char* displayLocale,
571            UChar* language,
572            int32_t languageCapacity,
573            UErrorCode* status);
574
575/**
576 * Gets the script name suitable for display for the specified locale.
577 *
578 * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
579 * @param displayLocale Specifies the locale to be used to display the name.  In other words,
580 *                 if the locale's language code is "en", passing Locale::getFrench() for
581 *                 inLocale would result in "", while passing Locale::getGerman()
582 *                 for inLocale would result in "". NULL may be used to specify the default.
583 * @param script the displayable script for the localeID
584 * @param scriptCapacity the size of the script buffer to store the  
585 * displayable script code with
586 * @param status error information if retrieving the displayable script code failed
587 * @return the actual buffer size needed for the displayable script code.  If it's greater 
588 * than scriptCapacity, the returned displayable script code will be truncated.  
589 * @stable ICU 2.8
590 */
591U_STABLE int32_t U_EXPORT2
592uloc_getDisplayScript(const char* locale,
593            const char* displayLocale,
594            UChar* script,
595            int32_t scriptCapacity,
596            UErrorCode* status);
597
598/**
599 * Gets the country name suitable for display for the specified locale.
600 * Warning: this is for the region part of a valid locale ID; it cannot just be the region code (like "FR").
601 * To get the display name for a region alone, or for other options, use ULocaleDisplayNames instead.
602 *
603 * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
604 * @param displayLocale Specifies the locale to be used to display the name.  In other words,
605 *                 if the locale's language code is "en", passing Locale::getFrench() for
606 *                 inLocale would result in "Anglais", while passing Locale::getGerman()
607 *                 for inLocale would result in "Englisch". NULL may be used to specify the default.
608 * @param country the displayable country code for localeID
609 * @param countryCapacity the size of the country buffer to store the  
610 * displayable country code with
611 * @param status error information if retrieving the displayable country code failed
612 * @return the actual buffer size needed for the displayable country code.  If it's greater 
613 * than countryCapacity, the returned displayable country code will be truncated.  
614 * @stable ICU 2.0
615 */
616U_STABLE int32_t U_EXPORT2
617uloc_getDisplayCountry(const char* locale,
618                       const char* displayLocale,
619                       UChar* country,
620                       int32_t countryCapacity,
621                       UErrorCode* status);
622
623
624/**
625 * Gets the variant name suitable for display for the specified locale.
626 *
627 * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
628 * @param displayLocale Specifies the locale to be used to display the name.  In other words,
629 *                 if the locale's language code is "en", passing Locale::getFrench() for
630 *                 inLocale would result in "Anglais", while passing Locale::getGerman()
631 *                 for inLocale would result in "Englisch". NULL may be used to specify the default.
632 * @param variant the displayable variant code for localeID
633 * @param variantCapacity the size of the variant buffer to store the 
634 * displayable variant code with
635 * @param status error information if retrieving the displayable variant code failed
636 * @return the actual buffer size needed for the displayable variant code.  If it's greater 
637 * than variantCapacity, the returned displayable variant code will be truncated.  
638 * @stable ICU 2.0
639 */
640U_STABLE int32_t U_EXPORT2
641uloc_getDisplayVariant(const char* locale,
642                       const char* displayLocale,
643                       UChar* variant,
644                       int32_t variantCapacity,
645                       UErrorCode* status);
646
647/**
648 * Gets the keyword name suitable for display for the specified locale.
649 * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display 
650 * string for the keyword collation. 
651 * Usage:
652 * <code>
653 *    UErrorCode status = U_ZERO_ERROR;
654 *    const char* keyword =NULL;
655 *    int32_t keywordLen = 0;
656 *    int32_t keywordCount = 0;
657 *    UChar displayKeyword[256];
658 *    int32_t displayKeywordLen = 0;
659 *    UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status);
660 *    for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){
661 *          if(U_FAILURE(status)){
662 *              ...something went wrong so handle the error...
663 *              break;
664 *          }
665 *          // the uenum_next returns NUL terminated string
666 *          keyword = uenum_next(keywordEnum, &keywordLen, &status);
667 *          displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256);
668 *          ... do something interesting .....
669 *    }
670 *    uenum_close(keywordEnum);
671 * </code>
672 * @param keyword           The keyword whose display string needs to be returned.
673 * @param displayLocale     Specifies the locale to be used to display the name.  In other words,
674 *                          if the locale's language code is "en", passing Locale::getFrench() for
675 *                          inLocale would result in "Anglais", while passing Locale::getGerman()
676 *                          for inLocale would result in "Englisch". NULL may be used to specify the default.
677 * @param dest              the buffer to which the displayable keyword should be written.
678 * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then
679 *                          dest may be NULL and the function will only return the length of the 
680 *                          result without writing any of the result string (pre-flighting).
681 * @param status            error information if retrieving the displayable string failed. 
682 *                          Should not be NULL and should not indicate failure on entry.
683 * @return the actual buffer size needed for the displayable variant code.  
684 * @see #uloc_openKeywords
685 * @stable ICU 2.8
686 */
687U_STABLE int32_t U_EXPORT2
688uloc_getDisplayKeyword(const char* keyword,
689                       const char* displayLocale,
690                       UChar* dest,
691                       int32_t destCapacity,
692                       UErrorCode* status);
693/**
694 * Gets the value of the keyword suitable for display for the specified locale.
695 * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display 
696 * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword.
697 *
698 * @param locale            The locale to get the displayable variant code with. NULL may be used to specify the default.
699 * @param keyword           The keyword for whose value should be used.
700 * @param displayLocale     Specifies the locale to be used to display the name.  In other words,
701 *                          if the locale's language code is "en", passing Locale::getFrench() for
702 *                          inLocale would result in "Anglais", while passing Locale::getGerman()
703 *                          for inLocale would result in "Englisch". NULL may be used to specify the default.
704 * @param dest              the buffer to which the displayable keyword should be written.
705 * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then
706 *                          dest may be NULL and the function will only return the length of the 
707 *                          result without writing any of the result string (pre-flighting).
708 * @param status            error information if retrieving the displayable string failed. 
709 *                          Should not be NULL and must not indicate failure on entry.
710 * @return the actual buffer size needed for the displayable variant code.  
711 * @stable ICU 2.8
712 */
713U_STABLE int32_t U_EXPORT2
714uloc_getDisplayKeywordValue(   const char* locale,
715                               const char* keyword,
716                               const char* displayLocale,
717                               UChar* dest,
718                               int32_t destCapacity,
719                               UErrorCode* status);
720/**
721 * Gets the full name suitable for display for the specified locale.
722 *
723 * @param localeID the locale to get the displayable name with. NULL may be used to specify the default.
724 * @param inLocaleID Specifies the locale to be used to display the name.  In other words,
725 *                   if the locale's language code is "en", passing Locale::getFrench() for
726 *                   inLocale would result in "Anglais", while passing Locale::getGerman()
727 *                   for inLocale would result in "Englisch". NULL may be used to specify the default.
728 * @param result the displayable name for localeID
729 * @param maxResultSize the size of the name buffer to store the 
730 * displayable full name with
731 * @param err error information if retrieving the displayable name failed
732 * @return the actual buffer size needed for the displayable name.  If it's greater 
733 * than maxResultSize, the returned displayable name will be truncated.  
734 * @stable ICU 2.0
735 */
736U_STABLE int32_t U_EXPORT2
737uloc_getDisplayName(const char* localeID,
738            const char* inLocaleID,
739            UChar* result,
740            int32_t maxResultSize,
741            UErrorCode* err);
742
743
744/**
745 * Gets the specified locale from a list of available locales.
746 *
747 * This method corresponds to uloc_openAvailableByType called with the
748 * ULOC_AVAILABLE_DEFAULT type argument.
749 *
750 * The return value is a pointer to an item of a locale name array. Both this
751 * array and the pointers it contains are owned by ICU and should not be
752 * deleted or written through by the caller. The locale name is terminated by
753 * a null pointer.
754 *
755 * @param n the specific locale name index of the available locale list;
756 *     should not exceed the number returned by uloc_countAvailable.
757 * @return a specified locale name of all available locales
758 * @stable ICU 2.0
759 */
760U_STABLE const char* U_EXPORT2
761uloc_getAvailable(int32_t n);
762
763/**
764 * Gets the size of the all available locale list.
765 *
766 * @return the size of the locale list
767 * @stable ICU 2.0
768 */
769U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
770
771#ifndef U_HIDE_DRAFT_API
772
773/**
774 * Types for uloc_getAvailableByType and uloc_countAvailableByType.
775 *
776 * @draft ICU 65
777 */
778typedef enum ULocAvailableType {
779  /**
780   * Locales that return data when passed to ICU APIs,
781   * but not including legacy or alias locales.
782   *
783   * @draft ICU 65
784   */
785  ULOC_AVAILABLE_DEFAULT,
786
787  /**
788   * Legacy or alias locales that return data when passed to ICU APIs.
789   * Examples of supported legacy or alias locales:
790   *
791   * - iw (alias to he)
792   * - mo (alias to ro)
793   * - zh_CN (alias to zh_Hans_CN)
794   * - sr_BA (alias to sr_Cyrl_BA)
795   * - ars (alias to ar_SA)
796   *
797   * The locales in this set are disjoint from the ones in
798   * ULOC_AVAILABLE_DEFAULT. To get both sets at the same time, use
799   * ULOC_AVAILABLE_WITH_LEGACY_ALIASES.
800   *
801   * @draft ICU 65
802   */
803  ULOC_AVAILABLE_ONLY_LEGACY_ALIASES,
804
805  /**
806   * The union of the locales in ULOC_AVAILABLE_DEFAULT and
807   * ULOC_AVAILABLE_ONLY_LEGACY_ALIAS.
808   *
809   * @draft ICU 65
810   */
811  ULOC_AVAILABLE_WITH_LEGACY_ALIASES,
812
813#ifndef U_HIDE_INTERNAL_API
814  /**
815   * @internal
816   */
817  ULOC_AVAILABLE_COUNT
818#endif
819} ULocAvailableType;
820
821/**
822 * Gets a list of available locales according to the type argument, allowing
823 * the user to access different sets of supported locales in ICU.
824 *
825 * The returned UEnumeration must be closed by the caller.
826 *
827 * @param type Type choice from ULocAvailableType.
828 * @param status Set if an error occurred.
829 * @return a UEnumeration owned by the caller, or nullptr on failure.
830 * @draft ICU 65
831 */
832U_DRAFT UEnumeration* U_EXPORT2
833uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status);
834
835#endif // U_HIDE_DRAFT_API
836
837/**
838 *
839 * Gets a list of all available 2-letter language codes defined in ISO 639,
840 * plus additional 3-letter codes determined to be useful for locale generation as
841 * defined by Unicode CLDR. This is a pointer
842 * to an array of pointers to arrays of char.  All of these pointers are owned
843 * by ICU-- do not delete them, and do not write through them.  The array is
844 * terminated with a null pointer.
845 * @return a list of all available language codes
846 * @stable ICU 2.0
847 */
848U_STABLE const char* const* U_EXPORT2
849uloc_getISOLanguages(void);
850
851/**
852 *
853 * Gets a list of all available 2-letter country codes defined in ISO 639.  This is a
854 * pointer to an array of pointers to arrays of char.  All of these pointers are
855 * owned by ICU-- do not delete them, and do not write through them.  The array is
856 * terminated with a null pointer.
857 * @return a list of all available country codes
858 * @stable ICU 2.0
859 */
860U_STABLE const char* const* U_EXPORT2
861uloc_getISOCountries(void);
862
863/**
864 * Truncate the locale ID string to get the parent locale ID.
865 * Copies the part of the string before the last underscore.
866 * The parent locale ID will be an empty string if there is no
867 * underscore, or if there is only one underscore at localeID[0].
868 *
869 * @param localeID Input locale ID string.
870 * @param parent   Output string buffer for the parent locale ID.
871 * @param parentCapacity Size of the output buffer.
872 * @param err A UErrorCode value.
873 * @return The length of the parent locale ID.
874 * @stable ICU 2.0
875 */
876U_STABLE int32_t U_EXPORT2
877uloc_getParent(const char*    localeID,
878                 char* parent,
879                 int32_t parentCapacity,
880                 UErrorCode* err);
881
882
883
884
885/**
886 * Gets the full name for the specified locale, like uloc_getName(),
887 * but without keywords.
888 *
889 * Note: This has the effect of 'canonicalizing' the string to
890 * a certain extent. Upper and lower case are set as needed,
891 * and if the components were in 'POSIX' format they are changed to
892 * ICU format.  It does NOT map aliased names in any way.
893 * See the top of this header file.
894 *
895 * This API strips off the keyword part, so "de_DE\@collation=phonebook" 
896 * will become "de_DE". 
897 * This API supports preflighting.
898 *
899 * @param localeID the locale to get the full name with
900 * @param name fill in buffer for the name without keywords.
901 * @param nameCapacity capacity of the fill in buffer.
902 * @param err error information if retrieving the full name failed
903 * @return the actual buffer size needed for the full name.  If it's greater 
904 * than nameCapacity, the returned full name will be truncated.  
905 * @stable ICU 2.8
906 */
907U_STABLE int32_t U_EXPORT2
908uloc_getBaseName(const char*    localeID,
909         char* name,
910         int32_t nameCapacity,
911         UErrorCode* err);
912
913/**
914 * Gets an enumeration of keywords for the specified locale. Enumeration
915 * must get disposed of by the client using uenum_close function.
916 *
917 * @param localeID the locale to get the variant code with
918 * @param status error information if retrieving the keywords failed
919 * @return enumeration of keywords or NULL if there are no keywords.
920 * @stable ICU 2.8
921 */
922U_STABLE UEnumeration* U_EXPORT2
923uloc_openKeywords(const char* localeID,
924                        UErrorCode* status);
925
926/**
927 * Get the value for a keyword. Locale name does not need to be normalized.
928 * 
929 * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK")
930 * @param keywordName name of the keyword for which we want the value; must not be
931 *  NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive.
932 * @param buffer receiving buffer
933 * @param bufferCapacity capacity of receiving buffer
934 * @param status containing error code: e.g. buffer not big enough or ill-formed localeID
935 *  or keywordName parameters.
936 * @return the length of keyword value
937 * @stable ICU 2.8
938 */
939U_STABLE int32_t U_EXPORT2
940uloc_getKeywordValue(const char* localeID,
941                     const char* keywordName,
942                     char* buffer, int32_t bufferCapacity,
943                     UErrorCode* status);
944
945
946/**
947 * Sets or removes the value of the specified keyword.
948 *
949 * For removing all keywords, use uloc_getBaseName().
950 *
951 * NOTE: Unlike almost every other ICU function which takes a
952 * buffer, this function will NOT truncate the output text, and will
953 * not update the buffer with unterminated text setting a status of
954 * U_STRING_NOT_TERMINATED_WARNING. If a BUFFER_OVERFLOW_ERROR is received,
955 * it means a terminated version of the updated locale ID would not fit
956 * in the buffer, and the original buffer is untouched. This is done to
957 * prevent incorrect or possibly even malformed locales from being generated
958 * and used.
959 *
960 * @param keywordName name of the keyword to be set; must not be
961 *  NULL or empty, and must consist only of [A-Za-z0-9]. Case insensitive.
962 * @param keywordValue value of the keyword to be set. If 0-length or
963 *  NULL, will result in the keyword being removed; no error is given if 
964 *  that keyword does not exist. Otherwise, must consist only of
965 *  [A-Za-z0-9] and [/_+-].
966 * @param buffer input buffer containing well-formed locale ID to be
967 *  modified.
968 * @param bufferCapacity capacity of receiving buffer
969 * @param status containing error code: e.g. buffer not big enough
970 *  or ill-formed keywordName or keywordValue parameters, or ill-formed
971 *  locale ID in buffer on input.
972 * @return the length needed for the buffer
973 * @see uloc_getKeywordValue
974 * @stable ICU 3.2
975 */
976U_STABLE int32_t U_EXPORT2
977uloc_setKeywordValue(const char* keywordName,
978                     const char* keywordValue,
979                     char* buffer, int32_t bufferCapacity,
980                     UErrorCode* status);
981
982/**
983 * Returns whether the locale's script is written right-to-left.
984 * If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
985 * If no likely script is known, then FALSE is returned.
986 *
987 * A script is right-to-left according to the CLDR script metadata
988 * which corresponds to whether the script's letters have Bidi_Class=R or AL.
989 *
990 * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
991 *
992 * @param locale input locale ID
993 * @return TRUE if the locale's script is written right-to-left
994 * @stable ICU 54
995 */
996U_STABLE UBool U_EXPORT2
997uloc_isRightToLeft(const char *locale);
998
999/**
1000 * enums for the  return value for the character and line orientation
1001 * functions.
1002 * @stable ICU 4.0
1003 */
1004typedef enum {
1005  ULOC_LAYOUT_LTR   = 0,  /* left-to-right. */
1006  ULOC_LAYOUT_RTL    = 1,  /* right-to-left. */
1007  ULOC_LAYOUT_TTB    = 2,  /* top-to-bottom. */
1008  ULOC_LAYOUT_BTT    = 3,   /* bottom-to-top. */
1009  ULOC_LAYOUT_UNKNOWN
1010} ULayoutType;
1011
1012/**
1013 * Get the layout character orientation for the specified locale.
1014 * 
1015 * @param localeId locale name
1016 * @param status Error status
1017 * @return an enum indicating the layout orientation for characters.
1018 * @stable ICU 4.0
1019 */
1020U_STABLE ULayoutType U_EXPORT2
1021uloc_getCharacterOrientation(const char* localeId,
1022                             UErrorCode *status);
1023
1024/**
1025 * Get the layout line orientation for the specified locale.
1026 * 
1027 * @param localeId locale name
1028 * @param status Error status
1029 * @return an enum indicating the layout orientation for lines.
1030 * @stable ICU 4.0
1031 */
1032U_STABLE ULayoutType U_EXPORT2
1033uloc_getLineOrientation(const char* localeId,
1034                        UErrorCode *status);
1035
1036/**
1037 * Output values which uloc_acceptLanguage() writes to the 'outResult' parameter.
1038 *
1039 * @see uloc_acceptLanguageFromHTTP
1040 * @see uloc_acceptLanguage
1041 * @stable ICU 3.2
1042 */
1043typedef enum {
1044    /**
1045     * No exact match was found.
1046     * @stable ICU 3.2
1047     */
1048    ULOC_ACCEPT_FAILED   = 0,
1049    /**
1050     * An exact match was found.
1051     * @stable ICU 3.2
1052     */
1053    ULOC_ACCEPT_VALID    = 1,
1054    /**
1055     * A fallback was found. For example, the Accept-Language list includes 'ja_JP'
1056     * and is matched with available locale 'ja'.
1057     * @stable ICU 3.2
1058     */
1059    ULOC_ACCEPT_FALLBACK = 2   /*  */
1060} UAcceptResult;
1061
1062/**
1063 * Based on a HTTP header from a web browser and a list of available locales,
1064 * determine an acceptable locale for the user.
1065 *
1066 * This is a thin wrapper over C++ class LocaleMatcher.
1067 *
1068 * @param result - buffer to accept the result locale
1069 * @param resultAvailable the size of the result buffer.
1070 * @param outResult - An out parameter that contains the fallback status
1071 * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP.
1072 * @param availableLocales - list of available locales to match
1073 * @param status ICU error code. Its input value must pass the U_SUCCESS() test,
1074 *               or else the function returns immediately. Check for U_FAILURE()
1075 *               on output or use with function chaining. (See User Guide for details.)
1076 * @return length needed for the locale.
1077 * @stable ICU 3.2
1078 */
1079U_STABLE int32_t U_EXPORT2
1080uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
1081                            UAcceptResult *outResult,
1082                            const char *httpAcceptLanguage,
1083                            UEnumeration* availableLocales,
1084                            UErrorCode *status);
1085
1086/**
1087 * Based on a list of available locales,
1088 * determine an acceptable locale for the user.
1089 *
1090 * This is a thin wrapper over C++ class LocaleMatcher.
1091 *
1092 * @param result - buffer to accept the result locale
1093 * @param resultAvailable the size of the result buffer.
1094 * @param outResult - An out parameter that contains the fallback status
1095 * @param acceptList - list of acceptable languages
1096 * @param acceptListCount - count of acceptList items
1097 * @param availableLocales - list of available locales to match
1098 * @param status ICU error code. Its input value must pass the U_SUCCESS() test,
1099 *               or else the function returns immediately. Check for U_FAILURE()
1100 *               on output or use with function chaining. (See User Guide for details.)
1101 * @return length needed for the locale.
1102 * @stable ICU 3.2
1103 */
1104U_STABLE int32_t U_EXPORT2
1105uloc_acceptLanguage(char *result, int32_t resultAvailable, 
1106                    UAcceptResult *outResult, const char **acceptList,
1107                    int32_t acceptListCount,
1108                    UEnumeration* availableLocales,
1109                    UErrorCode *status);
1110
1111
1112/**
1113 * Gets the ICU locale ID for the specified Win32 LCID value.
1114 *
1115 * @param hostID the Win32 LCID to translate
1116 * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated
1117 *  if there is room.
1118 * @param localeCapacity the size of the output buffer
1119 * @param status an error is returned if the LCID is unrecognized or the output buffer
1120 *  is too small
1121 * @return actual the actual size of the locale ID, not including NUL-termination 
1122 * @stable ICU 3.8
1123 */
1124U_STABLE int32_t U_EXPORT2
1125uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
1126                    UErrorCode *status);
1127
1128
1129/**
1130 * Add the likely subtags for a provided locale ID, per the algorithm described
1131 * in the following CLDR technical report:
1132 *
1133 *   http://www.unicode.org/reports/tr35/#Likely_Subtags
1134 *
1135 * If localeID is already in the maximal form, or there is no data available
1136 * for maximization, it will be copied to the output buffer.  For example,
1137 * "und-Zzzz" cannot be maximized, since there is no reasonable maximization.
1138 *
1139 * Examples:
1140 *
1141 * "en" maximizes to "en_Latn_US"
1142 *
1143 * "de" maximizes to "de_Latn_US"
1144 *
1145 * "sr" maximizes to "sr_Cyrl_RS"
1146 *
1147 * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
1148 *
1149 * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
1150 *
1151 * @param localeID The locale to maximize
1152 * @param maximizedLocaleID The maximized locale
1153 * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer
1154 * @param err Error information if maximizing the locale failed.  If the length
1155 * of the localeID and the null-terminator is greater than the maximum allowed size,
1156 * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
1157 * @return The actual buffer size needed for the maximized locale.  If it's
1158 * greater than maximizedLocaleIDCapacity, the returned ID will be truncated.
1159 * On error, the return value is -1.
1160 * @stable ICU 4.0
1161 */
1162U_STABLE int32_t U_EXPORT2
1163uloc_addLikelySubtags(const char*    localeID,
1164         char* maximizedLocaleID,
1165         int32_t maximizedLocaleIDCapacity,
1166         UErrorCode* err);
1167
1168
1169/**
1170 * Minimize the subtags for a provided locale ID, per the algorithm described
1171 * in the following CLDR technical report:
1172 *
1173 *   http://www.unicode.org/reports/tr35/#Likely_Subtags
1174 *
1175 * If localeID is already in the minimal form, or there is no data available
1176 * for minimization, it will be copied to the output buffer.  Since the
1177 * minimization algorithm relies on proper maximization, see the comments
1178 * for uloc_addLikelySubtags for reasons why there might not be any data.
1179 *
1180 * Examples:
1181 *
1182 * "en_Latn_US" minimizes to "en"
1183 *
1184 * "de_Latn_US" minimizes to "de"
1185 *
1186 * "sr_Cyrl_RS" minimizes to "sr"
1187 *
1188 * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
1189 * script, and minimizing to "zh" would imply "zh_Hans_CN".)
1190 *
1191 * @param localeID The locale to minimize
1192 * @param minimizedLocaleID The minimized locale
1193 * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer
1194 * @param err Error information if minimizing the locale failed.  If the length
1195 * of the localeID and the null-terminator is greater than the maximum allowed size,
1196 * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
1197 * @return The actual buffer size needed for the minimized locale.  If it's
1198 * greater than minimizedLocaleIDCapacity, the returned ID will be truncated.
1199 * On error, the return value is -1.
1200 * @stable ICU 4.0

Showing the first 1,200 of 1366 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai