ICU 76.1 76.1
Loading...
Searching...
No Matches
uloc.h
Go to the documentation of this file.
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
203#define ULOC_CHINESE "zh"
205#define ULOC_ENGLISH "en"
207#define ULOC_FRENCH "fr"
209#define ULOC_GERMAN "de"
211#define ULOC_ITALIAN "it"
213#define ULOC_JAPANESE "ja"
215#define ULOC_KOREAN "ko"
217#define ULOC_SIMPLIFIED_CHINESE "zh_CN"
219#define ULOC_TRADITIONAL_CHINESE "zh_TW"
220
222#define ULOC_CANADA "en_CA"
224#define ULOC_CANADA_FRENCH "fr_CA"
226#define ULOC_CHINA "zh_CN"
228#define ULOC_PRC "zh_CN"
230#define ULOC_FRANCE "fr_FR"
232#define ULOC_GERMANY "de_DE"
234#define ULOC_ITALY "it_IT"
236#define ULOC_JAPAN "ja_JP"
238#define ULOC_KOREA "ko_KR"
240#define ULOC_TAIWAN "zh_TW"
242#define ULOC_UK "en_GB"
244#define ULOC_US "en_US"
245
251#define ULOC_LANG_CAPACITY 12
252
258#define ULOC_COUNTRY_CAPACITY 4
264#define ULOC_FULLNAME_CAPACITY 157
265
271#define ULOC_SCRIPT_CAPACITY 6
272
277#define ULOC_KEYWORDS_CAPACITY 96
278
283#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
284
289#define ULOC_KEYWORD_SEPARATOR '@'
290
296#define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40
297
302#define ULOC_KEYWORD_ASSIGN '='
303
309#define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D
310
315#define ULOC_KEYWORD_ITEM_SEPARATOR ';'
316
322#define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B
323
338typedef enum {
347
348#ifndef U_HIDE_DEPRECATED_API
353
359#endif // U_HIDE_DEPRECATED_API
361
362#ifndef U_HIDE_SYSTEM_API
374U_CAPI const char* U_EXPORT2
376
394U_CAPI void U_EXPORT2
395uloc_setDefault(const char* localeID,
396 UErrorCode* status);
397#endif /* U_HIDE_SYSTEM_API */
398
414U_CAPI int32_t U_EXPORT2
415uloc_getLanguage(const char* localeID,
416 char* language,
417 int32_t languageCapacity,
418 UErrorCode* err);
419
435U_CAPI int32_t U_EXPORT2
436uloc_getScript(const char* localeID,
437 char* script,
438 int32_t scriptCapacity,
439 UErrorCode* err);
440
456U_CAPI int32_t U_EXPORT2
457uloc_getCountry(const char* localeID,
458 char* country,
459 int32_t countryCapacity,
460 UErrorCode* err);
461
477U_CAPI int32_t U_EXPORT2
478uloc_getVariant(const char* localeID,
479 char* variant,
480 int32_t variantCapacity,
481 UErrorCode* err);
482
483
504U_CAPI int32_t U_EXPORT2
505uloc_getName(const char* localeID,
506 char* name,
507 int32_t nameCapacity,
508 UErrorCode* err);
509
527U_CAPI int32_t U_EXPORT2
528uloc_canonicalize(const char* localeID,
529 char* name,
530 int32_t nameCapacity,
531 UErrorCode* err);
532
540U_CAPI const char* U_EXPORT2
541uloc_getISO3Language(const char* localeID);
542
543
551U_CAPI const char* U_EXPORT2
552uloc_getISO3Country(const char* localeID);
553
565U_CAPI uint32_t U_EXPORT2
566uloc_getLCID(const char* localeID);
567
589U_CAPI int32_t U_EXPORT2
590uloc_getDisplayLanguage(const char* locale,
591 const char* displayLocale,
592 UChar* language,
593 int32_t languageCapacity,
594 UErrorCode* status);
595
618U_CAPI int32_t U_EXPORT2
619uloc_getDisplayScript(const char* locale,
620 const char* displayLocale,
621 UChar* script,
622 int32_t scriptCapacity,
623 UErrorCode* status);
624
650U_CAPI int32_t U_EXPORT2
651uloc_getDisplayCountry(const char* locale,
652 const char* displayLocale,
653 UChar* country,
654 int32_t countryCapacity,
655 UErrorCode* status);
656
657
680U_CAPI int32_t U_EXPORT2
681uloc_getDisplayVariant(const char* locale,
682 const char* displayLocale,
683 UChar* variant,
684 int32_t variantCapacity,
685 UErrorCode* status);
686
729U_CAPI int32_t U_EXPORT2
730uloc_getDisplayKeyword(const char* keyword,
731 const char* displayLocale,
732 UChar* dest,
733 int32_t destCapacity,
734 UErrorCode* status);
757U_CAPI int32_t U_EXPORT2
758uloc_getDisplayKeywordValue( const char* locale,
759 const char* keyword,
760 const char* displayLocale,
761 UChar* dest,
762 int32_t destCapacity,
763 UErrorCode* status);
780U_CAPI int32_t U_EXPORT2
781uloc_getDisplayName(const char* localeID,
782 const char* inLocaleID,
783 UChar* result,
784 int32_t maxResultSize,
785 UErrorCode* err);
786
787
804U_CAPI const char* U_EXPORT2
806
813U_CAPI int32_t U_EXPORT2 uloc_countAvailable(void);
814
862
874U_CAPI UEnumeration* U_EXPORT2
876
888U_CAPI const char* const* U_EXPORT2
890
900U_CAPI const char* const* U_EXPORT2
902
916U_CAPI int32_t U_EXPORT2
917uloc_getParent(const char* localeID,
918 char* parent,
919 int32_t parentCapacity,
920 UErrorCode* err);
921
922
923
924
947U_CAPI int32_t U_EXPORT2
948uloc_getBaseName(const char* localeID,
949 char* name,
950 int32_t nameCapacity,
951 UErrorCode* err);
952
962U_CAPI UEnumeration* U_EXPORT2
963uloc_openKeywords(const char* localeID,
964 UErrorCode* status);
965
979U_CAPI int32_t U_EXPORT2
980uloc_getKeywordValue(const char* localeID,
981 const char* keywordName,
982 char* buffer, int32_t bufferCapacity,
983 UErrorCode* status);
984
985
1016U_CAPI int32_t U_EXPORT2
1017uloc_setKeywordValue(const char* keywordName,
1018 const char* keywordValue,
1019 char* buffer, int32_t bufferCapacity,
1020 UErrorCode* status);
1021
1036U_CAPI UBool U_EXPORT2
1037uloc_isRightToLeft(const char *locale);
1038
1044typedef enum {
1045 ULOC_LAYOUT_LTR = 0, /* left-to-right. */
1046 ULOC_LAYOUT_RTL = 1, /* right-to-left. */
1047 ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */
1048 ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */
1049 ULOC_LAYOUT_UNKNOWN
1050} ULayoutType;
1051
1060U_CAPI ULayoutType U_EXPORT2
1061uloc_getCharacterOrientation(const char* localeId,
1062 UErrorCode *status);
1063
1072U_CAPI ULayoutType U_EXPORT2
1073uloc_getLineOrientation(const char* localeId,
1074 UErrorCode *status);
1075
1101
1119U_CAPI int32_t U_EXPORT2
1120uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
1121 UAcceptResult *outResult,
1122 const char *httpAcceptLanguage,
1123 UEnumeration* availableLocales,
1124 UErrorCode *status);
1125
1144U_CAPI int32_t U_EXPORT2
1145uloc_acceptLanguage(char *result, int32_t resultAvailable,
1146 UAcceptResult *outResult, const char **acceptList,
1147 int32_t acceptListCount,
1148 UEnumeration* availableLocales,
1149 UErrorCode *status);
1150
1151
1164U_CAPI int32_t U_EXPORT2
1165uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
1166 UErrorCode *status);
1167
1168
1203U_CAPI int32_t U_EXPORT2
1204uloc_addLikelySubtags(const char* localeID,
1205 char* maximizedLocaleID,
1206 int32_t maximizedLocaleIDCapacity,
1207 UErrorCode* err);
1208
1209
1243U_CAPI int32_t U_EXPORT2
1244uloc_minimizeSubtags(const char* localeID,
1245 char* minimizedLocaleID,
1246 int32_t minimizedLocaleIDCapacity,
1247 UErrorCode* err);
1248
1276U_CAPI int32_t U_EXPORT2
1277uloc_forLanguageTag(const char* langtag,
1278 char* localeID,
1279 int32_t localeIDCapacity,
1280 int32_t* parsedLength,
1281 UErrorCode* err);
1282
1304U_CAPI int32_t U_EXPORT2
1305uloc_toLanguageTag(const char* localeID,
1306 char* langtag,
1307 int32_t langtagCapacity,
1308 UBool strict,
1309 UErrorCode* err);
1310
1332U_CAPI const char* U_EXPORT2
1333uloc_toUnicodeLocaleKey(const char* keyword);
1334
1363U_CAPI const char* U_EXPORT2
1364uloc_toUnicodeLocaleType(const char* keyword, const char* value);
1365
1378U_CAPI const char* U_EXPORT2
1379uloc_toLegacyKey(const char* keyword);
1380
1407U_CAPI const char* U_EXPORT2
1408uloc_toLegacyType(const char* keyword, const char* value);
1409
1410#endif /*_ULOC*/
C API: String Enumeration.
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:44
U_CAPI const char * uloc_toUnicodeLocaleType(const char *keyword, const char *value)
Converts the specified keyword value (legacy type, or BCP 47 Unicode locale extension type) to the we...
U_CAPI int32_t uloc_acceptLanguage(char *result, int32_t resultAvailable, UAcceptResult *outResult, const char **acceptList, int32_t acceptListCount, UEnumeration *availableLocales, UErrorCode *status)
Based on a list of available locales, determine an acceptable locale for the user.
U_CAPI UEnumeration * uloc_openAvailableByType(ULocAvailableType type, UErrorCode *status)
Gets a list of available locales according to the type argument, allowing the user to access differen...
U_CAPI const char * uloc_toLegacyType(const char *keyword, const char *value)
Converts the specified keyword value (BCP 47 Unicode locale extension type, or legacy type or type al...
U_CAPI ULayoutType uloc_getLineOrientation(const char *localeId, UErrorCode *status)
Get the layout line orientation for the specified locale.
U_CAPI int32_t uloc_toLanguageTag(const char *localeID, char *langtag, int32_t langtagCapacity, UBool strict, UErrorCode *err)
Returns a well-formed language tag for this locale ID.
U_CAPI int32_t uloc_getDisplayName(const char *localeID, const char *inLocaleID, UChar *result, int32_t maxResultSize, UErrorCode *err)
Gets the full name suitable for display for the specified locale.
UAcceptResult
Output values which uloc_acceptLanguage() writes to the 'outResult' parameter.
Definition uloc.h:1083
@ ULOC_ACCEPT_VALID
An exact match was found.
Definition uloc.h:1093
@ ULOC_ACCEPT_FALLBACK
A fallback was found.
Definition uloc.h:1099
@ ULOC_ACCEPT_FAILED
No exact match was found.
Definition uloc.h:1088
U_CAPI int32_t uloc_getDisplayVariant(const char *locale, const char *displayLocale, UChar *variant, int32_t variantCapacity, UErrorCode *status)
Gets the variant name suitable for display for the specified locale.
U_CAPI int32_t uloc_getDisplayScript(const char *locale, const char *displayLocale, UChar *script, int32_t scriptCapacity, UErrorCode *status)
Gets the script name suitable for display for the specified locale.
U_CAPI int32_t uloc_getVariant(const char *localeID, char *variant, int32_t variantCapacity, UErrorCode *err)
Gets the variant code for the specified locale.
U_CAPI int32_t uloc_getKeywordValue(const char *localeID, const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode *status)
Get the value for a keyword.
U_CAPI const char * uloc_getDefault(void)
Gets ICU's default locale.
ULayoutType
enums for the return value for the character and line orientation functions.
Definition uloc.h:1044
U_CAPI int32_t uloc_getLanguage(const char *localeID, char *language, int32_t languageCapacity, UErrorCode *err)
Gets the language code for the specified locale.
U_CAPI uint32_t uloc_getLCID(const char *localeID)
Gets the Win32 LCID value for the specified locale.
U_CAPI int32_t uloc_canonicalize(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale.
U_CAPI const char *const * uloc_getISOLanguages(void)
Gets a list of all available 2-letter language codes defined in ISO 639, plus additional 3-letter cod...
U_CAPI int32_t uloc_minimizeSubtags(const char *localeID, char *minimizedLocaleID, int32_t minimizedLocaleIDCapacity, UErrorCode *err)
Minimize the subtags for a provided locale ID, per the algorithm described in the following CLDR tech...
U_CAPI int32_t uloc_addLikelySubtags(const char *localeID, char *maximizedLocaleID, int32_t maximizedLocaleIDCapacity, UErrorCode *err)
Add the likely subtags for a provided locale ID, per the algorithm described in the following CLDR te...
U_CAPI int32_t uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, UAcceptResult *outResult, const char *httpAcceptLanguage, UEnumeration *availableLocales, UErrorCode *status)
Based on a HTTP header from a web browser and a list of available locales, determine an acceptable lo...
U_CAPI const char * uloc_toLegacyKey(const char *keyword)
Converts the specified keyword (BCP 47 Unicode locale extension key, or legacy key) to the legacy key...
U_CAPI int32_t uloc_getScript(const char *localeID, char *script, int32_t scriptCapacity, UErrorCode *err)
Gets the script code for the specified locale.
U_CAPI ULayoutType uloc_getCharacterOrientation(const char *localeId, UErrorCode *status)
Get the layout character orientation for the specified locale.
U_CAPI void uloc_setDefault(const char *localeID, UErrorCode *status)
Sets ICU's default locale.
U_CAPI int32_t uloc_getCountry(const char *localeID, char *country, int32_t countryCapacity, UErrorCode *err)
Gets the country code for the specified locale.
U_CAPI UBool uloc_isRightToLeft(const char *locale)
Returns whether the locale's script is written right-to-left.
U_CAPI const char * uloc_getAvailable(int32_t n)
Gets the specified locale from a list of available locales.
U_CAPI int32_t uloc_getParent(const char *localeID, char *parent, int32_t parentCapacity, UErrorCode *err)
Truncate the locale ID string to get the parent locale ID.
U_CAPI int32_t uloc_getBaseName(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale, like uloc_getName(), but without keywords.
U_CAPI int32_t uloc_getName(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale.
U_CAPI int32_t uloc_countAvailable(void)
Gets the size of the all available locale list.
U_CAPI int32_t uloc_forLanguageTag(const char *langtag, char *localeID, int32_t localeIDCapacity, int32_t *parsedLength, UErrorCode *err)
Returns a locale ID for the specified BCP47 language tag string.
U_CAPI const char *const * uloc_getISOCountries(void)
Gets a list of all available 2-letter country codes defined in ISO 639.
U_CAPI UEnumeration * uloc_openKeywords(const char *localeID, UErrorCode *status)
Gets an enumeration of keywords for the specified locale.
U_CAPI int32_t uloc_getDisplayKeyword(const char *keyword, const char *displayLocale, UChar *dest, int32_t destCapacity, UErrorCode *status)
Gets the keyword name suitable for display for the specified locale.
U_CAPI const char * uloc_toUnicodeLocaleKey(const char *keyword)
Converts the specified keyword (legacy key, or BCP 47 Unicode locale extension key) to the equivalent...
U_CAPI const char * uloc_getISO3Language(const char *localeID)
Gets the ISO language code for the specified locale.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
@ ULOC_DATA_LOCALE_TYPE_LIMIT
One more than the highest normal ULocDataLocaleType value.
Definition uloc.h:358
@ ULOC_ACTUAL_LOCALE
This is locale the data actually comes from.
Definition uloc.h:342
@ ULOC_VALID_LOCALE
This is the most specific locale supported by ICU.
Definition uloc.h:346
@ ULOC_REQUESTED_LOCALE
This is the requested locale.
Definition uloc.h:352
U_CAPI int32_t uloc_getDisplayCountry(const char *locale, const char *displayLocale, UChar *country, int32_t countryCapacity, UErrorCode *status)
Gets the country name suitable for display for the specified locale.
U_CAPI int32_t uloc_setKeywordValue(const char *keywordName, const char *keywordValue, char *buffer, int32_t bufferCapacity, UErrorCode *status)
Sets or removes the value of the specified keyword.
U_CAPI const char * uloc_getISO3Country(const char *localeID)
Gets the ISO country code for the specified locale.
U_CAPI int32_t uloc_getDisplayLanguage(const char *locale, const char *displayLocale, UChar *language, int32_t languageCapacity, UErrorCode *status)
Gets the language name suitable for display for the specified locale.
U_CAPI int32_t uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity, UErrorCode *status)
Gets the ICU locale ID for the specified Win32 LCID value.
ULocAvailableType
Types for uloc_getAvailableByType and uloc_countAvailableByType.
Definition uloc.h:820
@ ULOC_AVAILABLE_ONLY_LEGACY_ALIASES
Legacy or alias locales that return data when passed to ICU APIs.
Definition uloc.h:845
@ ULOC_AVAILABLE_COUNT
Definition uloc.h:859
@ ULOC_AVAILABLE_WITH_LEGACY_ALIASES
The union of the locales in ULOC_AVAILABLE_DEFAULT and ULOC_AVAILABLE_ONLY_LEGACY_ALIAS.
Definition uloc.h:853
@ ULOC_AVAILABLE_DEFAULT
Locales that return data when passed to ICU APIs, but not including legacy or alias locales.
Definition uloc.h:827
U_CAPI int32_t uloc_getDisplayKeywordValue(const char *locale, const char *keyword, const char *displayLocale, UChar *dest, int32_t destCapacity, UErrorCode *status)
Gets the value of the keyword suitable for display for the specified locale.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430