Loading...
Searching...
No Matches
uloc.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
* Copyright (C) 1997-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* File ULOC.H
*
* Modification History:
*
* Date Name Description
* 04/01/97 aliu Creation.
* 08/22/98 stephen JDK 1.2 sync.
* 12/08/98 rtg New C API for Locale
* 03/30/99 damiba overhaul
* 03/31/99 helena Javadoc for uloc functions.
* 04/15/99 Madhu Updated Javadoc
********************************************************************************
*/
#ifndef ULOC_H
#define ULOC_H
#include "unicode/utypes.h"
#include "unicode/uenum.h"
#define ULOC_CHINESE "zh"
#define ULOC_ENGLISH "en"
#define ULOC_FRENCH "fr"
#define ULOC_GERMAN "de"
#define ULOC_ITALIAN "it"
#define ULOC_JAPANESE "ja"
#define ULOC_KOREAN "ko"
#define ULOC_SIMPLIFIED_CHINESE "zh_CN"
#define ULOC_TRADITIONAL_CHINESE "zh_TW"
#define ULOC_CANADA "en_CA"
#define ULOC_CANADA_FRENCH "fr_CA"
#define ULOC_CHINA "zh_CN"
#define ULOC_PRC "zh_CN"
#define ULOC_FRANCE "fr_FR"
#define ULOC_GERMANY "de_DE"
#define ULOC_ITALY "it_IT"
#define ULOC_JAPAN "ja_JP"
#define ULOC_KOREA "ko_KR"
#define ULOC_TAIWAN "zh_TW"
#define ULOC_UK "en_GB"
#define ULOC_US "en_US"
#define ULOC_LANG_CAPACITY 12
#define ULOC_COUNTRY_CAPACITY 4
#define ULOC_FULLNAME_CAPACITY 157
#define ULOC_SCRIPT_CAPACITY 6
#define ULOC_KEYWORDS_CAPACITY 96
#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
#define ULOC_KEYWORD_SEPARATOR '@'
#define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40
#define ULOC_KEYWORD_ASSIGN '='
#define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D
#define ULOC_KEYWORD_ITEM_SEPARATOR ';'
#define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B
typedef enum {
ULOC_ACTUAL_LOCALE = 0,
ULOC_VALID_LOCALE = 1,
#ifndef U_HIDE_DEPRECATED_API
ULOC_REQUESTED_LOCALE = 2,
ULOC_DATA_LOCALE_TYPE_LIMIT = 3
#endif // U_HIDE_DEPRECATED_API
} ULocDataLocaleType;
#ifndef U_HIDE_SYSTEM_API
U_CAPI const char* U_EXPORT2
uloc_getDefault(void);
U_CAPI void U_EXPORT2
uloc_setDefault(const char* localeID,
UErrorCode* status);
#endif /* U_HIDE_SYSTEM_API */
U_CAPI int32_t U_EXPORT2
uloc_getLanguage(const char* localeID,
char* language,
int32_t languageCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_getScript(const char* localeID,
char* script,
int32_t scriptCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_getCountry(const char* localeID,
char* country,
int32_t countryCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_getVariant(const char* localeID,
char* variant,
int32_t variantCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_getName(const char* localeID,
char* name,
int32_t nameCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_canonicalize(const char* localeID,
char* name,
int32_t nameCapacity,
UErrorCode* err);
U_CAPI const char* U_EXPORT2
uloc_getISO3Language(const char* localeID);
U_CAPI const char* U_EXPORT2
uloc_getISO3Country(const char* localeID);
U_CAPI uint32_t U_EXPORT2
uloc_getLCID(const char* localeID);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayLanguage(const char* locale,
const char* displayLocale,
UChar* language,
int32_t languageCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayScript(const char* locale,
const char* displayLocale,
UChar* script,
int32_t scriptCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayCountry(const char* locale,
const char* displayLocale,
UChar* country,
int32_t countryCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayVariant(const char* locale,
const char* displayLocale,
UChar* variant,
int32_t variantCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeyword(const char* keyword,
const char* displayLocale,
UChar* dest,
int32_t destCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayKeywordValue( const char* locale,
const char* keyword,
const char* displayLocale,
UChar* dest,
int32_t destCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getDisplayName(const char* localeID,
const char* inLocaleID,
UChar* result,
int32_t maxResultSize,
UErrorCode* err);
U_CAPI const char* U_EXPORT2
uloc_getAvailable(int32_t n);
U_CAPI int32_t U_EXPORT2 uloc_countAvailable(void);
typedef enum ULocAvailableType {
ULOC_AVAILABLE_DEFAULT,
ULOC_AVAILABLE_ONLY_LEGACY_ALIASES,
ULOC_AVAILABLE_WITH_LEGACY_ALIASES,
#ifndef U_HIDE_INTERNAL_API
ULOC_AVAILABLE_COUNT
#endif /* U_HIDE_INTERNAL_API */
} ULocAvailableType;
U_CAPI UEnumeration* U_EXPORT2
uloc_openAvailableByType(ULocAvailableType type, UErrorCode* status);
U_CAPI const char* const* U_EXPORT2
uloc_getISOLanguages(void);
U_CAPI const char* const* U_EXPORT2
uloc_getISOCountries(void);
U_CAPI int32_t U_EXPORT2
uloc_getParent(const char* localeID,
char* parent,
int32_t parentCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_getBaseName(const char* localeID,
char* name,
int32_t nameCapacity,
UErrorCode* err);
U_CAPI UEnumeration* U_EXPORT2
uloc_openKeywords(const char* localeID,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_getKeywordValue(const char* localeID,
const char* keywordName,
char* buffer, int32_t bufferCapacity,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
uloc_setKeywordValue(const char* keywordName,
const char* keywordValue,
char* buffer, int32_t bufferCapacity,
UErrorCode* status);
U_CAPI UBool U_EXPORT2
uloc_isRightToLeft(const char *locale);
typedef enum {
ULOC_LAYOUT_LTR = 0, /* left-to-right. */
ULOC_LAYOUT_RTL = 1, /* right-to-left. */
ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */
ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */
ULOC_LAYOUT_UNKNOWN
} ULayoutType;
U_CAPI ULayoutType U_EXPORT2
uloc_getCharacterOrientation(const char* localeId,
UErrorCode *status);
U_CAPI ULayoutType U_EXPORT2
uloc_getLineOrientation(const char* localeId,
UErrorCode *status);
typedef enum {
ULOC_ACCEPT_FAILED = 0,
ULOC_ACCEPT_VALID = 1,
ULOC_ACCEPT_FALLBACK = 2 /* */
} UAcceptResult;
U_CAPI int32_t U_EXPORT2
uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
UAcceptResult *outResult,
const char *httpAcceptLanguage,
UEnumeration* availableLocales,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
uloc_acceptLanguage(char *result, int32_t resultAvailable,
UAcceptResult *outResult, const char **acceptList,
int32_t acceptListCount,
UEnumeration* availableLocales,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
uloc_addLikelySubtags(const char* localeID,
char* maximizedLocaleID,
int32_t maximizedLocaleIDCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_minimizeSubtags(const char* localeID,
char* minimizedLocaleID,
int32_t minimizedLocaleIDCapacity,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_forLanguageTag(const char* langtag,
char* localeID,
int32_t localeIDCapacity,
int32_t* parsedLength,
UErrorCode* err);
U_CAPI int32_t U_EXPORT2
uloc_toLanguageTag(const char* localeID,
char* langtag,
int32_t langtagCapacity,
UBool strict,
UErrorCode* err);
U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleKey(const char* keyword);
U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleType(const char* keyword, const char* value);
U_CAPI const char* U_EXPORT2
uloc_toLegacyKey(const char* keyword);
U_CAPI const char* U_EXPORT2
uloc_toLegacyType(const char* keyword, const char* value);
#endif /*_ULOC*/
uenum.h
C API: String Enumeration.
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:44
uloc_toUnicodeLocaleType
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...
uloc_acceptLanguage
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.
uloc_openAvailableByType
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...
uloc_toLegacyType
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...
uloc_getLineOrientation
U_CAPI ULayoutType uloc_getLineOrientation(const char *localeId, UErrorCode *status)
Get the layout line orientation for the specified locale.
uloc_toLanguageTag
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.
uloc_getDisplayName
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
UAcceptResult
Output values which uloc_acceptLanguage() writes to the 'outResult' parameter.
Definition uloc.h:1083
ULOC_ACCEPT_VALID
@ ULOC_ACCEPT_VALID
An exact match was found.
Definition uloc.h:1093
ULOC_ACCEPT_FALLBACK
@ ULOC_ACCEPT_FALLBACK
A fallback was found.
Definition uloc.h:1099
ULOC_ACCEPT_FAILED
@ ULOC_ACCEPT_FAILED
No exact match was found.
Definition uloc.h:1088
uloc_getDisplayVariant
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.
uloc_getDisplayScript
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.
uloc_getVariant
U_CAPI int32_t uloc_getVariant(const char *localeID, char *variant, int32_t variantCapacity, UErrorCode *err)
Gets the variant code for the specified locale.
uloc_getKeywordValue
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.
uloc_getDefault
U_CAPI const char * uloc_getDefault(void)
Gets ICU's default locale.
ULayoutType
ULayoutType
enums for the return value for the character and line orientation functions.
Definition uloc.h:1044
uloc_getLanguage
U_CAPI int32_t uloc_getLanguage(const char *localeID, char *language, int32_t languageCapacity, UErrorCode *err)
Gets the language code for the specified locale.
uloc_getLCID
U_CAPI uint32_t uloc_getLCID(const char *localeID)
Gets the Win32 LCID value for the specified locale.
uloc_canonicalize
U_CAPI int32_t uloc_canonicalize(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale.
uloc_getISOLanguages
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...
uloc_minimizeSubtags
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...
uloc_addLikelySubtags
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...
uloc_acceptLanguageFromHTTP
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...
uloc_toLegacyKey
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...
uloc_getScript
U_CAPI int32_t uloc_getScript(const char *localeID, char *script, int32_t scriptCapacity, UErrorCode *err)
Gets the script code for the specified locale.
uloc_getCharacterOrientation
U_CAPI ULayoutType uloc_getCharacterOrientation(const char *localeId, UErrorCode *status)
Get the layout character orientation for the specified locale.
uloc_setDefault
U_CAPI void uloc_setDefault(const char *localeID, UErrorCode *status)
Sets ICU's default locale.
uloc_getCountry
U_CAPI int32_t uloc_getCountry(const char *localeID, char *country, int32_t countryCapacity, UErrorCode *err)
Gets the country code for the specified locale.
uloc_isRightToLeft
U_CAPI UBool uloc_isRightToLeft(const char *locale)
Returns whether the locale's script is written right-to-left.
uloc_getAvailable
U_CAPI const char * uloc_getAvailable(int32_t n)
Gets the specified locale from a list of available locales.
uloc_getParent
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.
uloc_getBaseName
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.
uloc_getName
U_CAPI int32_t uloc_getName(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale.
uloc_countAvailable
U_CAPI int32_t uloc_countAvailable(void)
Gets the size of the all available locale list.
uloc_forLanguageTag
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.
uloc_getISOCountries
U_CAPI const char *const * uloc_getISOCountries(void)
Gets a list of all available 2-letter country codes defined in ISO 639.
uloc_openKeywords
U_CAPI UEnumeration * uloc_openKeywords(const char *localeID, UErrorCode *status)
Gets an enumeration of keywords for the specified locale.
uloc_getDisplayKeyword
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.
uloc_toUnicodeLocaleKey
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...
uloc_getISO3Language
U_CAPI const char * uloc_getISO3Language(const char *localeID)
Gets the ISO language code for the specified locale.
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
ULOC_DATA_LOCALE_TYPE_LIMIT
@ ULOC_DATA_LOCALE_TYPE_LIMIT
One more than the highest normal ULocDataLocaleType value.
Definition uloc.h:358
ULOC_ACTUAL_LOCALE
@ ULOC_ACTUAL_LOCALE
This is locale the data actually comes from.
Definition uloc.h:342
ULOC_VALID_LOCALE
@ ULOC_VALID_LOCALE
This is the most specific locale supported by ICU.
Definition uloc.h:346
ULOC_REQUESTED_LOCALE
@ ULOC_REQUESTED_LOCALE
This is the requested locale.
Definition uloc.h:352
uloc_getDisplayCountry
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.
uloc_setKeywordValue
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.
uloc_getISO3Country
U_CAPI const char * uloc_getISO3Country(const char *localeID)
Gets the ISO country code for the specified locale.
uloc_getDisplayLanguage
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.
uloc_getLocaleForLCID
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
ULocAvailableType
Types for uloc_getAvailableByType and uloc_countAvailableByType.
Definition uloc.h:820
ULOC_AVAILABLE_ONLY_LEGACY_ALIASES
@ ULOC_AVAILABLE_ONLY_LEGACY_ALIASES
Legacy or alias locales that return data when passed to ICU APIs.
Definition uloc.h:845
ULOC_AVAILABLE_COUNT
@ ULOC_AVAILABLE_COUNT
Definition uloc.h:859
ULOC_AVAILABLE_WITH_LEGACY_ALIASES
@ 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
@ ULOC_AVAILABLE_DEFAULT
Locales that return data when passed to ICU APIs, but not including legacy or alias locales.
Definition uloc.h:827
uloc_getDisplayKeywordValue
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.
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:400
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509