12e5b6d6dSopenharmony_ci--- 22e5b6d6dSopenharmony_cilayout: default 32e5b6d6dSopenharmony_cititle: Locales and Resources 42e5b6d6dSopenharmony_cinav_order: 800 52e5b6d6dSopenharmony_cihas_children: true 62e5b6d6dSopenharmony_ci--- 72e5b6d6dSopenharmony_ci<!-- 82e5b6d6dSopenharmony_ci© 2020 and later: Unicode, Inc. and others. 92e5b6d6dSopenharmony_ciLicense & terms of use: http://www.unicode.org/copyright.html 102e5b6d6dSopenharmony_ci--> 112e5b6d6dSopenharmony_ci 122e5b6d6dSopenharmony_ci# Locale 132e5b6d6dSopenharmony_ci{: .no_toc } 142e5b6d6dSopenharmony_ci 152e5b6d6dSopenharmony_ci## Contents 162e5b6d6dSopenharmony_ci{: .no_toc .text-delta } 172e5b6d6dSopenharmony_ci 182e5b6d6dSopenharmony_ci1. TOC 192e5b6d6dSopenharmony_ci{:toc} 202e5b6d6dSopenharmony_ci 212e5b6d6dSopenharmony_ci--- 222e5b6d6dSopenharmony_ci 232e5b6d6dSopenharmony_ci## Overview 242e5b6d6dSopenharmony_ci 252e5b6d6dSopenharmony_ciThis chapter explains **locales**, a fundamental concept in ICU. ICU services 262e5b6d6dSopenharmony_ciare parameterized by locale, to allow client code to be written in a 272e5b6d6dSopenharmony_cilocale-independent way, but to deliver culturally correct results. 282e5b6d6dSopenharmony_ci 292e5b6d6dSopenharmony_ci## The Locale Concept 302e5b6d6dSopenharmony_ci 312e5b6d6dSopenharmony_ciA locale identifies a specific user community - a group of users who have 322e5b6d6dSopenharmony_cisimilar culture and language expectations for human-computer interaction (and 332e5b6d6dSopenharmony_cithe kinds of data they process). 342e5b6d6dSopenharmony_ci 352e5b6d6dSopenharmony_ciA community is usually understood as the intersection of all users speaking the 362e5b6d6dSopenharmony_cisame language and living in the same country. Furthermore, a community can use 372e5b6d6dSopenharmony_cimore specific conventions. For example, an English/United States/Military locale 382e5b6d6dSopenharmony_ciis separate from the regular English/United States locale since the US military 392e5b6d6dSopenharmony_ciwrites times and dates differently than most of the civilian community. 402e5b6d6dSopenharmony_ci 412e5b6d6dSopenharmony_ciA program should be localized according to the rules specific for the target 422e5b6d6dSopenharmony_cilocale. Many ICU services rely on the proper locale identification in their 432e5b6d6dSopenharmony_cifunction. 442e5b6d6dSopenharmony_ci 452e5b6d6dSopenharmony_ciThe locale object in ICU is an identifier that specifies a particular locale and 462e5b6d6dSopenharmony_cihas fields for language, country, and an optional code to specify further 472e5b6d6dSopenharmony_civariants or subdivisions. These fields also can be represented as a string with 482e5b6d6dSopenharmony_cithe fields separated by an underscore. 492e5b6d6dSopenharmony_ci 502e5b6d6dSopenharmony_ciIn the C++ API, the locale is represented by the `Locale` class, which provides 512e5b6d6dSopenharmony_cimethods for finding language, country and variant components. In the C API the locale 522e5b6d6dSopenharmony_ciis defined simply by a character string. In the Java API, the locale is represented by 532e5b6d6dSopenharmony_ci`ULocale` which is analogous to the `Locale` class but provide additional support 542e5b6d6dSopenharmony_cifor ICU protocol. All the locale-sensitive ICU services use the locale information 552e5b6d6dSopenharmony_cito determine language and other locale specific parameters of their function. 562e5b6d6dSopenharmony_ciThe list of locale-sensitive services can be found in the Introduction to ICU 572e5b6d6dSopenharmony_cisection. Other parts of the library use the locale as an indicator to 582e5b6d6dSopenharmony_cicustomize their behavior. 592e5b6d6dSopenharmony_ci 602e5b6d6dSopenharmony_ciFor example, when the locale-sensitive date format service needs to format a 612e5b6d6dSopenharmony_cidate, it uses the convention appropriate to the current locale. If the locale is 622e5b6d6dSopenharmony_ciEnglish, it uses the word "Monday" and if it is French, it uses the word 632e5b6d6dSopenharmony_ci"Lundi". 642e5b6d6dSopenharmony_ci 652e5b6d6dSopenharmony_ciThe locale object also defines the concept of a default locale. The default 662e5b6d6dSopenharmony_cilocale is the locale, used by many programs, that regulates the rest of the 672e5b6d6dSopenharmony_cicomputer's behavior by default and is usually controlled by the user in a 682e5b6d6dSopenharmony_cicontrol panel window. The locale mechanism does not require a program to know 692e5b6d6dSopenharmony_ciwhich locale the user is using and thus makes most programming simpler. 702e5b6d6dSopenharmony_ci 712e5b6d6dSopenharmony_ciSince locale objects can be passed as parameters or stored in variables, the 722e5b6d6dSopenharmony_ciprogram does not have to know specifically which locales they identify. Many 732e5b6d6dSopenharmony_ciapplications enable a user to select a locale. The resulting locale object is 742e5b6d6dSopenharmony_cipassed as a parameter, which then produces the customized behavior for that 752e5b6d6dSopenharmony_cilocale. 762e5b6d6dSopenharmony_ci 772e5b6d6dSopenharmony_ciA locale provides a means of identifying a specific region for the purposes of 782e5b6d6dSopenharmony_ciinternationalization and localization. 792e5b6d6dSopenharmony_ci 802e5b6d6dSopenharmony_ci> :point_right: **Note**: An ICU locale is frequently confused with a Portable 812e5b6d6dSopenharmony_ci> Operating System Interface (POSIX) locale ID. An ICU locale ID is not a POSIX 822e5b6d6dSopenharmony_ci> locale ID. ICU locales do not specify the encoding and specify variant locales 832e5b6d6dSopenharmony_ci> differently. 842e5b6d6dSopenharmony_ci 852e5b6d6dSopenharmony_ciA locale consists of one or more pieces of ordered information: 862e5b6d6dSopenharmony_ci 872e5b6d6dSopenharmony_ci### Language code 882e5b6d6dSopenharmony_ci 892e5b6d6dSopenharmony_ciThe languages are specified using a two- or three-letter lowercase code for a 902e5b6d6dSopenharmony_ciparticular language. For example, Spanish is "es", English is "en" and French is 912e5b6d6dSopenharmony_ci"fr". The two-letter language code uses the 922e5b6d6dSopenharmony_ci[ISO-639](https://www.loc.gov/standards/iso639-2/) standard. 932e5b6d6dSopenharmony_ci 942e5b6d6dSopenharmony_ci### Script code 952e5b6d6dSopenharmony_ci 962e5b6d6dSopenharmony_ciThe optional four-letter script code follows the language code. If specified, it 972e5b6d6dSopenharmony_cishould be a valid script code as listed on the 982e5b6d6dSopenharmony_ci[Unicode ISO 15924 Registry](https://www.unicode.org/iso15924/iso15924-codes.html). 992e5b6d6dSopenharmony_ci 1002e5b6d6dSopenharmony_ci### Country code 1012e5b6d6dSopenharmony_ci 1022e5b6d6dSopenharmony_ciThere are often different language conventions within the same language. For 1032e5b6d6dSopenharmony_ciexample, Spanish is spoken in many countries in Central and South America but 1042e5b6d6dSopenharmony_cithe currencies are different in each country. To allow for these differences 1052e5b6d6dSopenharmony_ciamong specific geographical, political, or cultural regions, locales are 1062e5b6d6dSopenharmony_cispecified by two-letter, uppercase codes. For example, "ES" represents Spain and 1072e5b6d6dSopenharmony_ci"MX" represents Mexico. The two letter country code uses the 1082e5b6d6dSopenharmony_ci[ISO-3166](https://www.iso.org/iso-3166-country-codes.html) standard. 1092e5b6d6dSopenharmony_ci 1102e5b6d6dSopenharmony_ciJava supports two letter country codes that uses ISO-3166 and UN M.49 code. 1112e5b6d6dSopenharmony_ci 1122e5b6d6dSopenharmony_ci### Variant code 1132e5b6d6dSopenharmony_ci 1142e5b6d6dSopenharmony_ciDifferences may also appear in language conventions used within the same 1152e5b6d6dSopenharmony_cicountry. For example, the Euro currency is used in several European countries 1162e5b6d6dSopenharmony_ciwhile the individual country's currency is still in circulation. Variations 1172e5b6d6dSopenharmony_ciinside a language and country pair are handled by adding a third code, the 1182e5b6d6dSopenharmony_civariant code. The variant code is arbitrary and completely application-specific. 1192e5b6d6dSopenharmony_ciICU adds "_EURO" to its locale designations for locales that support the Euro 1202e5b6d6dSopenharmony_cicurrency. Variants can have any number of underscored key words. For example, 1212e5b6d6dSopenharmony_ci"EURO_WIN" is a variant for the Euro currency on a Windows computer. 1222e5b6d6dSopenharmony_ci 1232e5b6d6dSopenharmony_ciAnother use of the variant code is to designate the Collation (sorting order) of 1242e5b6d6dSopenharmony_cia locale. For instance, the "es__TRADITIONAL" locale uses the traditional 1252e5b6d6dSopenharmony_cisorting order which is different from the default modern sorting of Spanish. 1262e5b6d6dSopenharmony_ci 1272e5b6d6dSopenharmony_ciCollation order and currency can be more flexibly specified using keywords 1282e5b6d6dSopenharmony_ciinstead of variants; see below. 1292e5b6d6dSopenharmony_ci 1302e5b6d6dSopenharmony_ci### Keywords 1312e5b6d6dSopenharmony_ci 1322e5b6d6dSopenharmony_ciThe final element of a locale is an optional list of keywords together with 1332e5b6d6dSopenharmony_citheir values. Keywords must be unique. Their order is not significant. Unknown 1342e5b6d6dSopenharmony_cikeywords are ignored. The handling of keywords depends on the specific services 1352e5b6d6dSopenharmony_cithat utilize them. Currently, the following keywords are recognized: 1362e5b6d6dSopenharmony_ci 1372e5b6d6dSopenharmony_ciKeyword | Possible Values | Description 1382e5b6d6dSopenharmony_ci--------|-----------------|------------ 1392e5b6d6dSopenharmony_cicalendar | A calendar specifier such as "gregorian", "islamic", "chinese", "islamic-civil", "hebrew", "japanese", or "buddhist". See the Key/Type Definitions table in the [Locale Data Markup Language](http://www.unicode.org/reports/tr35/) for a list of recognized values. | If present, the calendar keyword specifies the calendar type that the `Calendar` factory methods create. See the calendar locale and keyword handling section (§) of the [Calendar Classes](../datetime/calendar/index.md) chapter for details. 1402e5b6d6dSopenharmony_cicollation | A collation specifier such as "phonebook", "pinyin", "traditional", "stroke", "direct", or "posix". See the Key/Type Definitions table in the [Locale Data Markup Language](http://www.unicode.org/reports/tr35/) for a list of recognized values. | If present, the collation keyword modifies how the collation service searches through the locale data when instantiating a collator. See the collation locale and keyword handling section (§) of the [Collation Services Architecture](../collation/architecture.md) chapter for details. 1412e5b6d6dSopenharmony_cicurrency | Any standard three-letter currency code, such as "USD" or "JPY". See the LocaleExplorer [currency list](https://icu4c-demos.unicode.org/icu-bin/locexp?_=en&SHOWCurrencies=1#Currencies) for a list of currently recognized currency codes. | If present, the currency keyword is used by `NumberFormat` to determine the currency to use to format a currency value, and by `ucurr_forLocale()` to specify a currency. 1422e5b6d6dSopenharmony_cinumbers | A numbering system specifier such as "latn", "arab", "deva", "hansfin" or "thai". See the Key/Type Definitions table in the [Locale Data Markup Language](http://www.unicode.org/reports/tr35/) for a list of recognized values. | If present, the numbers keyword is used by `NumberFormat` to determine the numbering system to be used for formatting and parsing numbers. The numbering system defines the set of digits used for decimal formatting, such as "latn" for western (ASCII) digits, or "thai" for Thai digits. The numbering system may also define complex algorithms for number formatting, such as "hansfin" for simplified Chinese numerals using financial ideographs. 1432e5b6d6dSopenharmony_ci 1442e5b6d6dSopenharmony_ciIf any of these keywords is absent, the service requesting it will typically use 1452e5b6d6dSopenharmony_cithe rest of the locale specifier in order to determine the appropriate behavior 1462e5b6d6dSopenharmony_cifor the locale. The keywords allow a locale specifier to override or refine this 1472e5b6d6dSopenharmony_cidefault behavior. 1482e5b6d6dSopenharmony_ci 1492e5b6d6dSopenharmony_ci### Examples 1502e5b6d6dSopenharmony_ci 1512e5b6d6dSopenharmony_ciLocale ID | Language | Script | Country | Variant | Keywords | Definition 1522e5b6d6dSopenharmony_ci----------|----------|--------|---------|---------|----------|----------- 1532e5b6d6dSopenharmony_cien_US | en | | US | | | English, United States of America. <br>Browse in [LocaleExplorer](https://icu4c-demos.unicode.org/icu-bin/locexp?_=en_US) 1542e5b6d6dSopenharmony_cien_IE_PREEURO | en | | IE | | | English, Ireland. <br>Browse in [LocaleExplorer](https://icu4c-demos.unicode.org/icu-bin/locexp?_=en_IE_PREEURO) 1552e5b6d6dSopenharmony_cien_IE@currency=IEP | en | | IE | | currency=IEP | English, Ireland with Irish Pound. <br>Browse in [LocaleExplorer](https://icu4c-demos.unicode.org/icu-bin/locexp?_=en_IE@currency=IEP) 1562e5b6d6dSopenharmony_cieo | eo | | | | | Esperanto. <br>Browse in [LocaleExplorer](https://icu4c-demos.unicode.org/icu-bin/locexp?_=eo) 1572e5b6d6dSopenharmony_cifr@collation=phonebook;calendar=islamic-civil | fr | | | | collation=phonebook <br>calendar=islamic-civil | French (Calendar=Islamic-Civil Calendar, Collation=Phonebook Order). <br>Browse in [LocaleExplorer](https://icu4c-demos.unicode.org/icu-bin/locexp?_=fr@collation=phonebook;calendar=islamic-civil) 1582e5b6d6dSopenharmony_cisr_Latn_RS_REVISED@currency=USD | sr | Latn | RS | REVISED | currency=USD | Serbian (Latin, Yugoslavia, Revised Orthography, Currency=US Dollar) <br>Browse in [LocaleExplorer](https://icu4c-demos.unicode.org/icu-bin/locexp?d_=en&_=sr_Latn_RS_REVISED@currency=USD) 1592e5b6d6dSopenharmony_ci 1602e5b6d6dSopenharmony_ci 1612e5b6d6dSopenharmony_ci### Default Locales 1622e5b6d6dSopenharmony_ci 1632e5b6d6dSopenharmony_ciDefault locales are available to all the objects in a program. If you set a new 1642e5b6d6dSopenharmony_cidefault locale for one section of code, it can affect the entire program. 1652e5b6d6dSopenharmony_ciApplication programs should not set the default locale as a way to request an 1662e5b6d6dSopenharmony_ciinternational object. The default locale is set to be the system locale on that 1672e5b6d6dSopenharmony_ciplatform. 1682e5b6d6dSopenharmony_ci 1692e5b6d6dSopenharmony_ciFor example, when you set the default locale, the change affects the default 1702e5b6d6dSopenharmony_cibehavior of the `Collator` and `NumberFormat` instances. When the default locale is 1712e5b6d6dSopenharmony_cinot wanted, you can set the desired locale using a factory method supplied with 1722e5b6d6dSopenharmony_cithe classes such as `Collator::createInstance()`. 1732e5b6d6dSopenharmony_ci 1742e5b6d6dSopenharmony_ciUsing the ICU C functions, `NULL` can be passed for a locale parameter to specify 1752e5b6d6dSopenharmony_cithe default locale. 1762e5b6d6dSopenharmony_ci 1772e5b6d6dSopenharmony_ci## Locales and Services 1782e5b6d6dSopenharmony_ci 1792e5b6d6dSopenharmony_ciICU is implemented as a set of services. One example of a service is the 1802e5b6d6dSopenharmony_ciformatting of a numeric value into a string. Another is the sorting of a list of 1812e5b6d6dSopenharmony_cistrings. When client code wants to use a service, the first thing it does is 1822e5b6d6dSopenharmony_cirequest a service object for a given locale. The resulting object is then 1832e5b6d6dSopenharmony_ciexpected to perform the its operations in a way that is culturally correct for 1842e5b6d6dSopenharmony_cithe requested locale. 1852e5b6d6dSopenharmony_ci 1862e5b6d6dSopenharmony_ci### Requested Locale 1872e5b6d6dSopenharmony_ci 1882e5b6d6dSopenharmony_ciThe **requested** locale is the one specified by the client code when the 1892e5b6d6dSopenharmony_ciservice object is requested. 1902e5b6d6dSopenharmony_ci 1912e5b6d6dSopenharmony_ci### Valid Locale 1922e5b6d6dSopenharmony_ci 1932e5b6d6dSopenharmony_ciA **populated** locale is one for which ICU has data, or one in which client 1942e5b6d6dSopenharmony_cicode has registered a service. If the requested locale is not populated, then 1952e5b6d6dSopenharmony_ciICU will fallback until it reaches a populated locale. The first populated 1962e5b6d6dSopenharmony_cilocale it reaches is the **valid** locale. The 1972e5b6d6dSopenharmony_civalid locale is reachable from the requested locale via zero or more fallback 1982e5b6d6dSopenharmony_cisteps. 1992e5b6d6dSopenharmony_ci 2002e5b6d6dSopenharmony_ci### Fallback 2012e5b6d6dSopenharmony_ci 2022e5b6d6dSopenharmony_ciLocale **fallback** proceeds as follows: 2032e5b6d6dSopenharmony_ci 2042e5b6d6dSopenharmony_ci1. The variant is removed, if there is one. 2052e5b6d6dSopenharmony_ci 2062e5b6d6dSopenharmony_ci2. The country is removed, if there is one. 2072e5b6d6dSopenharmony_ci 2082e5b6d6dSopenharmony_ci3. The script is removed, if there is one. 2092e5b6d6dSopenharmony_ci 2102e5b6d6dSopenharmony_ci4. The ICU default locale is examined. The same set of steps is performed for 2112e5b6d6dSopenharmony_ci the default locale. 2122e5b6d6dSopenharmony_ci 2132e5b6d6dSopenharmony_ciAt any point, if the desired data is found, then the fallback procedure stops. 2142e5b6d6dSopenharmony_ciKeywords are not altered during fallback until the default locale is reached, at 2152e5b6d6dSopenharmony_ciwhich point all keywords are replaced by those assigned to the default locale. 2162e5b6d6dSopenharmony_ci 2172e5b6d6dSopenharmony_ci### Actual Locale 2182e5b6d6dSopenharmony_ci 2192e5b6d6dSopenharmony_ciServices request specific resources within the valid locale. If the valid locale 2202e5b6d6dSopenharmony_cidirectly contains the requested resource, then it is the **actual** locale. If 2212e5b6d6dSopenharmony_cinot, then ICU will fallback until it reaches a locale that does directly contain 2222e5b6d6dSopenharmony_cithe requested resource. The first such locale is the actual locale. The actual 2232e5b6d6dSopenharmony_cilocale is reachable from the valid locale via zero or more fallback steps. 2242e5b6d6dSopenharmony_ci 2252e5b6d6dSopenharmony_ci### getLocale() 2262e5b6d6dSopenharmony_ci 2272e5b6d6dSopenharmony_ciClient code may wish to know what the valid and actual locales are for a given 2282e5b6d6dSopenharmony_ciservice object. To support this, ICU services provide the method `getLocale()`. 2292e5b6d6dSopenharmony_ciThe `getLocale()` method takes an argument specifying whether the actual or 2302e5b6d6dSopenharmony_civalid locale is to be returned. 2312e5b6d6dSopenharmony_ci 2322e5b6d6dSopenharmony_ciSome service object will have an empty or null return from `getLocale()`. This 2332e5b6d6dSopenharmony_ciindicates that the given service object was not created from locale data, or 2342e5b6d6dSopenharmony_cithat it has since been modified so that it no longer reflects locale data, 2352e5b6d6dSopenharmony_citypically through alteration of the pattern (but not localized symbol changes -- 2362e5b6d6dSopenharmony_cisuch changes do not reset the actual and valid locale settings). 2372e5b6d6dSopenharmony_ci 2382e5b6d6dSopenharmony_ciCurrently, the services that support the `getLocale()` API are the following 2392e5b6d6dSopenharmony_ciclasses and their subclasses: 2402e5b6d6dSopenharmony_ci 2412e5b6d6dSopenharmony_ci### Functional Equivalence 2422e5b6d6dSopenharmony_ci 2432e5b6d6dSopenharmony_ciVarious services provide the API `getFunctionalEquivalent` to allow callers 2442e5b6d6dSopenharmony_cidetermine the **functionally equivalent locale** for a requested locale. For 2452e5b6d6dSopenharmony_ciexample, when instantiating a collator for the locale `en_US_CALIFORNIA`, the 2462e5b6d6dSopenharmony_cifunctionally equivalent locale may be `en`. 2472e5b6d6dSopenharmony_ci 2482e5b6d6dSopenharmony_ciThe purpose of this is to allow applications to do intelligent caching. If an 2492e5b6d6dSopenharmony_ciapplication opens a service object for locale A with a functional equivalent Q 2502e5b6d6dSopenharmony_ciand caches it, then later when it requires a service object for locale B, it can 2512e5b6d6dSopenharmony_cifirst check if locale B has the **same functional equivalent** as locale A; if 2522e5b6d6dSopenharmony_ciso, it can reuse the cached A object for the B locale, and be guaranteed the 2532e5b6d6dSopenharmony_cisame results as if it has instantiated a service object for B. In other words, 2542e5b6d6dSopenharmony_ci 2552e5b6d6dSopenharmony_ci``` 2562e5b6d6dSopenharmony_ciService.getFunctionalEquivalent(A) == Service.getFunctionalEquivalent(B) 2572e5b6d6dSopenharmony_ci``` 2582e5b6d6dSopenharmony_ci 2592e5b6d6dSopenharmony_ciimplies that the object returned by `Service.getInstance(A)` will behave 2602e5b6d6dSopenharmony_ciequivalently to the object returned by `Service.getInstance(B)`. 2612e5b6d6dSopenharmony_ci 2622e5b6d6dSopenharmony_ciHere is a pseudo-code example: 2632e5b6d6dSopenharmony_ci 2642e5b6d6dSopenharmony_ciThe functional equivalent locale returned by a service has no meaning beyond 2652e5b6d6dSopenharmony_ciwhat is stated above. For example, if the functional equivalent of Greek is 2662e5b6d6dSopenharmony_ciHebrew for collation, that makes no statement about the linguistic relation of 2672e5b6d6dSopenharmony_cithe languages -- it only means that the two collators are functionally 2682e5b6d6dSopenharmony_ciequivalent. 2692e5b6d6dSopenharmony_ci 2702e5b6d6dSopenharmony_ciWhile two locales with the same functional equivalent are guaranteed to be 2712e5b6d6dSopenharmony_ciequivalent, the converse is **not** true: If two locales are in fact equivalent, 2722e5b6d6dSopenharmony_cithey may **not** return the same result from `getFunctionalEquivalent`. That is, 2732e5b6d6dSopenharmony_ciif the object returned by `Service.getInstance(A)` behaves equivalently to the 2742e5b6d6dSopenharmony_ciobject returned by `Service.getInstance(B)`, `Service.getFunctionalEquivalent(A)` 2752e5b6d6dSopenharmony_ci**may or may not** be equal to `Service.getFunctionalEquivalent(B)`. Take again 2762e5b6d6dSopenharmony_cithe example of Greek and Hebrew, with respect to collation. These locales may 2772e5b6d6dSopenharmony_cihappen to be functional equivalents (since they each just turn on full 2782e5b6d6dSopenharmony_cinormalization), but it may or may not be the case that they return the same 2792e5b6d6dSopenharmony_cifunctionally equivalent locale. This depends on how the data is structured 2802e5b6d6dSopenharmony_ciinternally. 2812e5b6d6dSopenharmony_ci 2822e5b6d6dSopenharmony_ciThe functional equivalent for a locale may change over time. Suppose that Greek 2832e5b6d6dSopenharmony_ciwere enhanced to change sorting of additional ancient Greek characters. In that 2842e5b6d6dSopenharmony_cicase, it would diverge; the functional equivalent of Greek would no longer be 2852e5b6d6dSopenharmony_ciHebrew. 2862e5b6d6dSopenharmony_ci 2872e5b6d6dSopenharmony_ci## Canonicalization 2882e5b6d6dSopenharmony_ci 2892e5b6d6dSopenharmony_ciICU works with **ICU format locale IDs**. These are strings that obey the 2902e5b6d6dSopenharmony_cifollowing character set and syntax restrictions: 2912e5b6d6dSopenharmony_ci 2922e5b6d6dSopenharmony_ci1. The only permitted characters are ASCII letters, hyphen ('-'), underscore 2932e5b6d6dSopenharmony_ci ('_'), at-sign ('@'), equals sign ('='), and semicolon (';'). 2942e5b6d6dSopenharmony_ci 2952e5b6d6dSopenharmony_ci2. IDs consist of either a base name, keyword list, or both. If a keyword list 2962e5b6d6dSopenharmony_ci is present it must be preceded by an at-sign. 2972e5b6d6dSopenharmony_ci 2982e5b6d6dSopenharmony_ci3. The base name must precede the keyword list, if both are present. 2992e5b6d6dSopenharmony_ci 3002e5b6d6dSopenharmony_ci4. The base name defines the language, script, country, and variant, and can 3012e5b6d6dSopenharmony_ci contain only ASCII letters, hyphen, or underscore. 3022e5b6d6dSopenharmony_ci 3032e5b6d6dSopenharmony_ci5. The keyword list consists of keyword/value pairs. Each keyword or value 3042e5b6d6dSopenharmony_ci consists of one or more ASCII letters, hyphen, or underscore. Keywords and 3052e5b6d6dSopenharmony_ci values are separated by a single equals sign. Multiple keyword/value pairs, 3062e5b6d6dSopenharmony_ci if present, are separated by a single semicolon. A keyword may not appear 3072e5b6d6dSopenharmony_ci without a value. The same keyword may not appear twice. 3082e5b6d6dSopenharmony_ci 3092e5b6d6dSopenharmony_ciICU performs two kinds of canonicalizing operations on 'ICU format' locale IDs. 3102e5b6d6dSopenharmony_ciLevel 1 canonicalization is performed routinely and automatically by ICU APIs. 3112e5b6d6dSopenharmony_ciThe recommended procedure for client code using locale IDs from outside sources 3122e5b6d6dSopenharmony_ci(e.g., POSIX, user input, etc.) is to pass such "foreign IDs" through level 2 3132e5b6d6dSopenharmony_cicanonicalization before use. 3142e5b6d6dSopenharmony_ci 3152e5b6d6dSopenharmony_ci**Level 1 canonicalization**. This operation performs minor, isolated changes, 3162e5b6d6dSopenharmony_cisuch as changing "en-us" to "en_US". Level 1 canonicalization is **not** 3172e5b6d6dSopenharmony_cidesigned to handle "foreign" locale IDs (POSIX, .NET) but rather IDs that are in 3182e5b6d6dSopenharmony_ciICU format, but which do not have normalized case and delimiters. Level 1 3192e5b6d6dSopenharmony_cicanonicalization is accomplished by the ICU functions `uloc_getName`, 3202e5b6d6dSopenharmony_ci`Locale::createFromName`, and `Locale::Locale`. The latter two APIs exist in both 3212e5b6d6dSopenharmony_ciC++ and Java. 3222e5b6d6dSopenharmony_ci 3232e5b6d6dSopenharmony_ci1. Level 1 canonicalization is defined only on ICU format locale IDs as defined 3242e5b6d6dSopenharmony_ci above. Behavior with any other kind of input is unspecified. 3252e5b6d6dSopenharmony_ci 3262e5b6d6dSopenharmony_ci2. Case is normalized. Elements interpreted as **language** strings will be 3272e5b6d6dSopenharmony_ci converted to lowercase. **Country** and **variant** elements will be 3282e5b6d6dSopenharmony_ci converted to uppercase. **Script** elements will be title-cased. **Keywords** 3292e5b6d6dSopenharmony_ci will be converted to lowercase. **Keyword values** will remain unchanged. 3302e5b6d6dSopenharmony_ci 3312e5b6d6dSopenharmony_ci3. Hyphens are converted to underscores. 3322e5b6d6dSopenharmony_ci 3332e5b6d6dSopenharmony_ci4. All 3-letter country codes are converted to 2-letter equivalents. 3342e5b6d6dSopenharmony_ci 3352e5b6d6dSopenharmony_ci5. Any 3-letter language codes are converted to 2-letter equivalents if 3362e5b6d6dSopenharmony_ci possible. 3-letter language codes with no 2-letter equivalent are kept as 3372e5b6d6dSopenharmony_ci 3-letter codes. 3382e5b6d6dSopenharmony_ci 3392e5b6d6dSopenharmony_ci6. Keywords are sorted. 3402e5b6d6dSopenharmony_ci 3412e5b6d6dSopenharmony_ci**Level 2 canonicalization**. This operation may make major changes to the ID, 3422e5b6d6dSopenharmony_cipossibly replacing entire elements of the ID. An example is changing 3432e5b6d6dSopenharmony_ci"fr-fr@EURO" to "fr_FR@currency=EUR". Level 2 canonicalization is designed to 3442e5b6d6dSopenharmony_citranslate POSIX and .NET IDs, as well as nonstandard ICU locale IDs. Level 2 is 3452e5b6d6dSopenharmony_cia **superset** of level 1; every operation performed by level 1 is also 3462e5b6d6dSopenharmony_ciperformed by level 2. Level 2 canonicalization is performed by `uloc_canonicalize` 3472e5b6d6dSopenharmony_ciand `Locale::createCanonical`. The latter API exists in both C++ and Java. 3482e5b6d6dSopenharmony_ci 3492e5b6d6dSopenharmony_ci1. Level 2 canonicalization operates on ICU format locale IDs with the 3502e5b6d6dSopenharmony_ci following additions: 3512e5b6d6dSopenharmony_ci 3522e5b6d6dSopenharmony_ci 1. The period ('.') is also a valid input character. 3532e5b6d6dSopenharmony_ci 3542e5b6d6dSopenharmony_ci 2. An at-sign may be followed by text that is not a keyword/value pair. If 3552e5b6d6dSopenharmony_ci present, such text is added to the variant. 3562e5b6d6dSopenharmony_ci 3572e5b6d6dSopenharmony_ci2. POSIX variants are normalized, e.g., "en_US@VARIANT" => "en_US_VARIANT". 3582e5b6d6dSopenharmony_ci 3592e5b6d6dSopenharmony_ci3. POSIX charset specifiers are **deleted**, e.g. "en_US.utf8" => "en_US". 3602e5b6d6dSopenharmony_ci 3612e5b6d6dSopenharmony_ci4. The variant "EURO" is converted to the keyword specifier "currency=EUR". 3622e5b6d6dSopenharmony_ci This conversion applies to both "fr_FR_EURO" and "fr_FR@EURO" style IDs. 3632e5b6d6dSopenharmony_ci 3642e5b6d6dSopenharmony_ci5. The variant "PREEURO" is converted to the keyword specifier "currency=K", 3652e5b6d6dSopenharmony_ci where K is the 3-letter currency code for the country's national currency in 3662e5b6d6dSopenharmony_ci effect at the time of the euro transitiion. This conversion applies to both 3672e5b6d6dSopenharmony_ci "fr_FR_PREURO" and "fr_FR@PREURO" style IDs. This mapping is only performed 3682e5b6d6dSopenharmony_ci for the following locales: ca_ES (ESP), de_AT (ATS), de_DE (DEM), de_LU 3692e5b6d6dSopenharmony_ci (EUR), el_GR (GRD), en_BE (BEF), en_IE (IEP), es_ES (ESP), eu_ES (ESP), 3702e5b6d6dSopenharmony_ci fi_FI (FIM), fr_BE (BEF), fr_FR (FRF), fr_LU (LUF), ga_IE (IEP), gl_ES 3712e5b6d6dSopenharmony_ci (ESP), it_IT (ITL), nl_BE (BEF), nl_NL (NLG), pt_PT (PTE). 3722e5b6d6dSopenharmony_ci 3732e5b6d6dSopenharmony_ci6. The following IANA registered ISO 3066 names are remapped: art_LOJBAN => 3742e5b6d6dSopenharmony_ci jbo, cel_GAULISH => cel__GAULISH, de_1901 => de__1901, de_1906 => de__1906, 3752e5b6d6dSopenharmony_ci en_BOONT => en__BOONT, en_SCOUSE => en__SCOUSE, sl_ROZAJ => sl__ROZAJ, 3762e5b6d6dSopenharmony_ci zh_GAN => zh__GAN, zh_GUOYU => zh, zh_HAKKA => zh__HAKKA, zh_MIN => zh__MIN, 3772e5b6d6dSopenharmony_ci zh_MIN_NAN => zh__MINNAN, zh_WUU => zh__WUU, zh_XIANG => zh__XIANG, zh_YUE 3782e5b6d6dSopenharmony_ci => zh__YUE. 3792e5b6d6dSopenharmony_ci 3802e5b6d6dSopenharmony_ci7. The following .NET identifiers are remapped: "" (empty string) => 3812e5b6d6dSopenharmony_ci en_US_POSIX, az_AZ_CYRL => az_Cyrl_AZ, az_AZ_LATN => az_Latn_AZ, sr_SP_CYRL 3822e5b6d6dSopenharmony_ci => sr_Cyrl_SP, sr_SP_LATN => sr_Latn_SP, uz_UZ_CYRL => uz_Cyrl_UZ, 3832e5b6d6dSopenharmony_ci uz_UZ_LATN => uz_Latn_UZ, zh_CHS => zh_Hans, zh_CHT => zh_Hant. The empty 3842e5b6d6dSopenharmony_ci string is not remapped if a keyword list is present. 3852e5b6d6dSopenharmony_ci 3862e5b6d6dSopenharmony_ci8. Variants specifying collation are remapped to collation keyword specifiers, 3872e5b6d6dSopenharmony_ci as follows: de__PHONEBOOK => de@collation=phonebook, es__TRADITIONAL => 3882e5b6d6dSopenharmony_ci es@collation=traditional, hi__DIRECT => hi@collation=direct, zh_TW_STROKE => 3892e5b6d6dSopenharmony_ci zh_TW@collation=stroke, zh__PINYIN => zh@collation=pinyin. 3902e5b6d6dSopenharmony_ci 3912e5b6d6dSopenharmony_ci9. Variants specifying a calendar are remapped to calendar keyword specifiers, 3922e5b6d6dSopenharmony_ci as follows: ja_JP_TRADITIONAL => ja_JP@calendar=japanese, th_TH_TRADITIONAL 3932e5b6d6dSopenharmony_ci => th_TH@calendar=buddhist. 3942e5b6d6dSopenharmony_ci 3952e5b6d6dSopenharmony_ci10. Special case: C => en_US_POSIX. 3962e5b6d6dSopenharmony_ci 3972e5b6d6dSopenharmony_ciCertain other operations are not performed by either level 1 or level 2 3982e5b6d6dSopenharmony_cicanonicalization. These are listed here for completeness. 3992e5b6d6dSopenharmony_ci 4002e5b6d6dSopenharmony_ci1. Language identifiers that have been superseded will not be remapped. In 4012e5b6d6dSopenharmony_ci particular, the following transformations are not performed: 4022e5b6d6dSopenharmony_ci 4032e5b6d6dSopenharmony_ci 1. no => nb 4042e5b6d6dSopenharmony_ci 4052e5b6d6dSopenharmony_ci 2. iw => he 4062e5b6d6dSopenharmony_ci 4072e5b6d6dSopenharmony_ci 3. id => in 4082e5b6d6dSopenharmony_ci 4092e5b6d6dSopenharmony_ci 4. nb_no_NY => nn_NO 4102e5b6d6dSopenharmony_ci 4112e5b6d6dSopenharmony_ci2. The behavior of level 2 canonicalization when presented with a remapped ID 4122e5b6d6dSopenharmony_ci combined together with keywords is not defined. For example, 4132e5b6d6dSopenharmony_ci fr_FR_EURO@currency=FRF has an undefined level 2 canonicalization. 4142e5b6d6dSopenharmony_ci 4152e5b6d6dSopenharmony_ciAll APIs (with a few exceptions) in ICU4C that take a `const char* locale` 4162e5b6d6dSopenharmony_ciparameter can be assumed to automatically peform level 1 canonicalization before 4172e5b6d6dSopenharmony_ciusing the locale ID to do resource lookup, keyword interpretation, etc. 4182e5b6d6dSopenharmony_ciSpecifically, the static API `getLanguage`, `getScript`, `getCountry`, and `getVariant` 4192e5b6d6dSopenharmony_cibehave exactly like their non-static counterparts in the class `Locale`. That is, 4202e5b6d6dSopenharmony_cifor any locale ID `loc`, `new Locale(loc).getFoo() == Locale::getFoo(loc)`, where 4212e5b6d6dSopenharmony_ciFoo is one of Language, Script, Country, or Variant. 4222e5b6d6dSopenharmony_ci 4232e5b6d6dSopenharmony_ciThe `Locale` constructor (in C++ and Java) taking multiple strings behaves exactly 4242e5b6d6dSopenharmony_cias if those strings were concatenated, with the '_' separator inserted between 4252e5b6d6dSopenharmony_citwo adjacent non-empty strings, and the result passed to `uloc_getName`. 4262e5b6d6dSopenharmony_ci 4272e5b6d6dSopenharmony_ci> :point_right: **Note**: Throughout this discussion `Locale` refers to both the 4282e5b6d6dSopenharmony_ci> C++ `Locale` class and the ICU4J `com.ibm.icu.util.ULocale` class. Although C++ 4292e5b6d6dSopenharmony_ci> notation is used, all statements made regarding `Locale` apply equally to 4302e5b6d6dSopenharmony_ci> `com.ibm.icu.util.ULocale`. 4312e5b6d6dSopenharmony_ci 4322e5b6d6dSopenharmony_ci## Usage: Creating Locales 4332e5b6d6dSopenharmony_ci 4342e5b6d6dSopenharmony_ciIf you are localizing an application to a locale that is not already supported, 4352e5b6d6dSopenharmony_ciyou need to create your own `Locale` object. New `Locale` objects are created using 4362e5b6d6dSopenharmony_cione of the three constructors in this class: 4372e5b6d6dSopenharmony_ci 4382e5b6d6dSopenharmony_ci```c++ 4392e5b6d6dSopenharmony_ciLocale( const char * language); 4402e5b6d6dSopenharmony_ciLocale( const char * language, const char * country); 4412e5b6d6dSopenharmony_ciLocale( const char * language, const char * country, const char * variant); 4422e5b6d6dSopenharmony_ci``` 4432e5b6d6dSopenharmony_ci 4442e5b6d6dSopenharmony_ciBecause a locale object is just an identifier for a region, no validity check is 4452e5b6d6dSopenharmony_ciperformed. If you want to verify that the particular resources are available for 4462e5b6d6dSopenharmony_cithe locale you construct, you must query those resources. For example, you can 4472e5b6d6dSopenharmony_ciquery the `NumberFormat` object for the locales it supports using its 4482e5b6d6dSopenharmony_ci`getAvailableLocales()` method. 4492e5b6d6dSopenharmony_ci 4502e5b6d6dSopenharmony_ciNew `ULocale` objects in Java are created using one the following three 4512e5b6d6dSopenharmony_ciconstructor in this class: 4522e5b6d6dSopenharmony_ci 4532e5b6d6dSopenharmony_ci```java 4542e5b6d6dSopenharmony_ciULocale( String localeID) 4552e5b6d6dSopenharmony_ciULocale( String a, String b) 4562e5b6d6dSopenharmony_ciULocale( String a, String b, String c) 4572e5b6d6dSopenharmony_ci``` 4582e5b6d6dSopenharmony_ci 4592e5b6d6dSopenharmony_ciThe locale ID passed in the constructor consists of optional languages, scripts, 4602e5b6d6dSopenharmony_cicountry and variant fields in that oder, separated by underscore, followed by an 4612e5b6d6dSopenharmony_cioptional keywords. For example, "en_US", "sy_Cyrl_YU", "zh__pinyin", 4622e5b6d6dSopenharmony_ci"es_ES@currency=EUR,collation=traditional". The fields a, b, c in the other two 4632e5b6d6dSopenharmony_ciconstructors are the components of the locale ID. For example, the following two 4642e5b6d6dSopenharmony_cilocale object are same: 4652e5b6d6dSopenharmony_ci 4662e5b6d6dSopenharmony_ci```java 4672e5b6d6dSopenharmony_ciULocale ul = new Ulocale("sy_Cyrl_YU"); 4682e5b6d6dSopenharmony_ciULocale ul = new ULocale("sy", "Cyrl", "YU"); 4692e5b6d6dSopenharmony_ci``` 4702e5b6d6dSopenharmony_ci 4712e5b6d6dSopenharmony_ciIn C++, the `Locale` class provides a number of convenient constants that you can 4722e5b6d6dSopenharmony_ciuse to create locales. For example, the following refers to a `NumberFormat` object 4732e5b6d6dSopenharmony_cifor the United States: 4742e5b6d6dSopenharmony_ci 4752e5b6d6dSopenharmony_ci```c++ 4762e5b6d6dSopenharmony_ciLocale::getUS() 4772e5b6d6dSopenharmony_ci``` 4782e5b6d6dSopenharmony_ci 4792e5b6d6dSopenharmony_ciIn C, a string with the language country and variant concatenated together with 4802e5b6d6dSopenharmony_cian underscore '_' describe a locale. For example, "en_US" is a locale that is 4812e5b6d6dSopenharmony_cibased on the English language in the United States. The following can be used as 4822e5b6d6dSopenharmony_ciequivalents to the locale constants: 4832e5b6d6dSopenharmony_ci 4842e5b6d6dSopenharmony_ci```c 4852e5b6d6dSopenharmony_ciULOC_US 4862e5b6d6dSopenharmony_ci``` 4872e5b6d6dSopenharmony_ci 4882e5b6d6dSopenharmony_ciIn Java, the `ULocale` provides a number of convenient constants that can be used 4892e5b6d6dSopenharmony_cito create locales. 4902e5b6d6dSopenharmony_ci 4912e5b6d6dSopenharmony_ci```java 4922e5b6d6dSopenharmony_ciULocale.US; 4932e5b6d6dSopenharmony_ci``` 4942e5b6d6dSopenharmony_ci 4952e5b6d6dSopenharmony_ci## Usage: Retrieving Locales 4962e5b6d6dSopenharmony_ci 4972e5b6d6dSopenharmony_ciLocale-sensitive classes have a `getAvailableLocales()` method that returns all of 4982e5b6d6dSopenharmony_cithe locales supported by that class. This method also shows the other methods 4992e5b6d6dSopenharmony_cithat get locale information from the resource bundle. For example, the following 5002e5b6d6dSopenharmony_cishows that the `NumberFormat` class provides three convenience methods for 5012e5b6d6dSopenharmony_cicreating a default `NumberFormat` object: 5022e5b6d6dSopenharmony_ci 5032e5b6d6dSopenharmony_ci```c++ 5042e5b6d6dSopenharmony_ciNumberFormat::createInstance(); 5052e5b6d6dSopenharmony_ciNumberFormat::createCurrencyInstance(); 5062e5b6d6dSopenharmony_ciNumberFormat::createPercentInstance(); 5072e5b6d6dSopenharmony_ci``` 5082e5b6d6dSopenharmony_ci 5092e5b6d6dSopenharmony_ciLocale-sensitive classes in Java also have a `getAvailableULocales()` method that 5102e5b6d6dSopenharmony_cireturns all of the locales supported by that class. 5112e5b6d6dSopenharmony_ci 5122e5b6d6dSopenharmony_ci### Displayable Names 5132e5b6d6dSopenharmony_ci 5142e5b6d6dSopenharmony_ciOnce you've created a `Locale` in C++ and a `ULocale` in java, you can perform a 5152e5b6d6dSopenharmony_ciquery of the locale for information about itself. The following shows the 5162e5b6d6dSopenharmony_ciinformation you can receive from a locale: 5172e5b6d6dSopenharmony_ci 5182e5b6d6dSopenharmony_ciMethod | Description 5192e5b6d6dSopenharmony_ci-------|------------ 5202e5b6d6dSopenharmony_ci`getCountry()` | Retrieves the ISO Country Code 5212e5b6d6dSopenharmony_ci`getLanguage()` | Retrieves the ISO Language 5222e5b6d6dSopenharmony_ci`getDisplayCountry()` | Shows the name of the country suitable for displaying information to the user 5232e5b6d6dSopenharmony_ci`getDisplayLanguage()` | Shows the name of the language suitable for displaying to the user 5242e5b6d6dSopenharmony_ci 5252e5b6d6dSopenharmony_ci> :point_right: **Note**: The `getDisplayXXX` methods are themselves locale-sensitive 5262e5b6d6dSopenharmony_ci> and have two versions in C++: one that uses the default locale and one that takes a 5272e5b6d6dSopenharmony_ci> locale as an argument and displays the name or country in a language appropriate to 5282e5b6d6dSopenharmony_ci> that locale. 5292e5b6d6dSopenharmony_ci 5302e5b6d6dSopenharmony_ci> :point_right: **Note**: In Java, the `getDisplayXXX` methods have three versions: 5312e5b6d6dSopenharmony_ci> one that uses the default locale, the other takes a locale as an argument and the 5322e5b6d6dSopenharmony_ci> third one which takes locale ID as an argument. 5332e5b6d6dSopenharmony_ci 5342e5b6d6dSopenharmony_ciEach class that performs locale-sensitive operations allows you to get all the 5352e5b6d6dSopenharmony_ciavailable objects of that type. You can sift through these objects by language, 5362e5b6d6dSopenharmony_cicountry, or variant, and use the display names to present a menu to the user. 5372e5b6d6dSopenharmony_ciFor example, you can create a menu of all the collation objects suitable for a 5382e5b6d6dSopenharmony_cigiven language. 5392e5b6d6dSopenharmony_ci 5402e5b6d6dSopenharmony_ci### HTTP Accept-Language 5412e5b6d6dSopenharmony_ci 5422e5b6d6dSopenharmony_ciICU provides functions to negotiate the best locale to use for an operation, 5432e5b6d6dSopenharmony_cigiven a user's list of acceptable locales, and the application's list of 5442e5b6d6dSopenharmony_ciavailable locales. For example, a browser sends the web server the HTTP 5452e5b6d6dSopenharmony_ci"`Accept-Language`" header indicating which locales, with a ranking, are 5462e5b6d6dSopenharmony_ciacceptable to the user. The server must determine which locale to use when 5472e5b6d6dSopenharmony_cireturning content to the user. 5482e5b6d6dSopenharmony_ci 5492e5b6d6dSopenharmony_ciHere is an example of selecting an acceptable locale within a CGI application: 5502e5b6d6dSopenharmony_ci 5512e5b6d6dSopenharmony_ciC: 5522e5b6d6dSopenharmony_ci 5532e5b6d6dSopenharmony_ci```c 5542e5b6d6dSopenharmony_cichar resultLocale[200]; 5552e5b6d6dSopenharmony_ciUAcceptResult outResult; 5562e5b6d6dSopenharmony_ciavailable = ures_openAvailableLocales("myBundle", &status); 5572e5b6d6dSopenharmony_ciint32_t len = uloc_acceptLanguageFromHTTP(resultLocale, 200, &outResult, 5582e5b6d6dSopenharmony_ci getenv("HTTP_ACCEPT_LANGUAGE"), available, &status); 5592e5b6d6dSopenharmony_ciif(U_SUCCESS(status)) { 5602e5b6d6dSopenharmony_ci printf("Using locale %s\n", outResult); 5612e5b6d6dSopenharmony_ci} 5622e5b6d6dSopenharmony_ci``` 5632e5b6d6dSopenharmony_ci 5642e5b6d6dSopenharmony_ciHere is an example of selecting an acceptable locale within a Java application: 5652e5b6d6dSopenharmony_ci 5662e5b6d6dSopenharmony_ciJava: 5672e5b6d6dSopenharmony_ci 5682e5b6d6dSopenharmony_ci```java 5692e5b6d6dSopenharmony_ciULocale[] availableLocales = ULocale.getAvailableLocales(); 5702e5b6d6dSopenharmony_ciboolean[] fallback = { false }; 5712e5b6d6dSopenharmony_ciULocale result = ULocale.acceptLanguage(availableLocales, fallback); 5722e5b6d6dSopenharmony_ci 5732e5b6d6dSopenharmony_ciSystem.out.println("Using locale " + result); 5742e5b6d6dSopenharmony_ci``` 5752e5b6d6dSopenharmony_ci 5762e5b6d6dSopenharmony_ci> :point_right: **Note**: As of this writing, this functionality is available in 5772e5b6d6dSopenharmony_ci> both C and Java. Please read the following two linked documents for important 5782e5b6d6dSopenharmony_ci> considerations and recommendations when using this header in a web application. 5792e5b6d6dSopenharmony_ci 5802e5b6d6dSopenharmony_ci> *For further information about the Accept-Language HTTP header:* <br> 5812e5b6d6dSopenharmony_ci> https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 <br> 5822e5b6d6dSopenharmony_ci> *Notes and cautions about the use of this header:* <br> 5832e5b6d6dSopenharmony_ci> https://www.w3.org/International/questions/qa-accept-lang-locales 5842e5b6d6dSopenharmony_ci 5852e5b6d6dSopenharmony_ci## Programming in C vs. C++ vs. Java 5862e5b6d6dSopenharmony_ci 5872e5b6d6dSopenharmony_ciSee Programming for Locale in [C, C++ and Java](examples.md) for more information. 588