ICU 57.1 57.1
uloc.h
Go to the documentation of this file.
1/*
2**********************************************************************
3* Copyright (C) 1997-2016, International Business Machines
4* Corporation and others. All Rights Reserved.
5**********************************************************************
6*
7* File ULOC.H
8*
9* Modification History:
10*
11* Date Name Description
12* 04/01/97 aliu Creation.
13* 08/22/98 stephen JDK 1.2 sync.
14* 12/08/98 rtg New C API for Locale
15* 03/30/99 damiba overhaul
16* 03/31/99 helena Javadoc for uloc functions.
17* 04/15/99 Madhu Updated Javadoc
18********************************************************************************
19*/
20
21#ifndef ULOC_H
22#define ULOC_H
23
24#include "unicode/utypes.h"
25#include "unicode/uenum.h"
26
201#define ULOC_CHINESE "zh"
203#define ULOC_ENGLISH "en"
205#define ULOC_FRENCH "fr"
207#define ULOC_GERMAN "de"
209#define ULOC_ITALIAN "it"
211#define ULOC_JAPANESE "ja"
213#define ULOC_KOREAN "ko"
215#define ULOC_SIMPLIFIED_CHINESE "zh_CN"
217#define ULOC_TRADITIONAL_CHINESE "zh_TW"
218
220#define ULOC_CANADA "en_CA"
222#define ULOC_CANADA_FRENCH "fr_CA"
224#define ULOC_CHINA "zh_CN"
226#define ULOC_PRC "zh_CN"
228#define ULOC_FRANCE "fr_FR"
230#define ULOC_GERMANY "de_DE"
232#define ULOC_ITALY "it_IT"
234#define ULOC_JAPAN "ja_JP"
236#define ULOC_KOREA "ko_KR"
238#define ULOC_TAIWAN "zh_TW"
240#define ULOC_UK "en_GB"
242#define ULOC_US "en_US"
243
249#define ULOC_LANG_CAPACITY 12
250
256#define ULOC_COUNTRY_CAPACITY 4
262#define ULOC_FULLNAME_CAPACITY 157
263
269#define ULOC_SCRIPT_CAPACITY 6
270
275#define ULOC_KEYWORDS_CAPACITY 96
276
281#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
282
287#define ULOC_KEYWORD_SEPARATOR '@'
288
294#define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40
295
300#define ULOC_KEYWORD_ASSIGN '='
301
307#define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D
308
313#define ULOC_KEYWORD_ITEM_SEPARATOR ';'
314
320#define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B
321
336typedef enum {
345
346#ifndef U_HIDE_DEPRECATED_API
351#endif /* U_HIDE_DEPRECATED_API */
352
353 ULOC_DATA_LOCALE_TYPE_LIMIT = 3
355
356#ifndef U_HIDE_SYSTEM_API
368U_STABLE const char* U_EXPORT2
370
388U_STABLE void U_EXPORT2
389uloc_setDefault(const char* localeID,
390 UErrorCode* status);
391#endif /* U_HIDE_SYSTEM_API */
392
405U_STABLE int32_t U_EXPORT2
406uloc_getLanguage(const char* localeID,
407 char* language,
408 int32_t languageCapacity,
409 UErrorCode* err);
410
423U_STABLE int32_t U_EXPORT2
424uloc_getScript(const char* localeID,
425 char* script,
426 int32_t scriptCapacity,
427 UErrorCode* err);
428
441U_STABLE int32_t U_EXPORT2
442uloc_getCountry(const char* localeID,
443 char* country,
444 int32_t countryCapacity,
445 UErrorCode* err);
446
459U_STABLE int32_t U_EXPORT2
460uloc_getVariant(const char* localeID,
461 char* variant,
462 int32_t variantCapacity,
463 UErrorCode* err);
464
465
482U_STABLE int32_t U_EXPORT2
483uloc_getName(const char* localeID,
484 char* name,
485 int32_t nameCapacity,
486 UErrorCode* err);
487
505U_STABLE int32_t U_EXPORT2
506uloc_canonicalize(const char* localeID,
507 char* name,
508 int32_t nameCapacity,
509 UErrorCode* err);
510
518U_STABLE const char* U_EXPORT2
519uloc_getISO3Language(const char* localeID);
520
521
529U_STABLE const char* U_EXPORT2
530uloc_getISO3Country(const char* localeID);
531
540U_STABLE uint32_t U_EXPORT2
541uloc_getLCID(const char* localeID);
542
559U_STABLE int32_t U_EXPORT2
560uloc_getDisplayLanguage(const char* locale,
561 const char* displayLocale,
562 UChar* language,
563 int32_t languageCapacity,
564 UErrorCode* status);
565
582U_STABLE int32_t U_EXPORT2
583uloc_getDisplayScript(const char* locale,
584 const char* displayLocale,
585 UChar* script,
586 int32_t scriptCapacity,
587 UErrorCode* status);
588
607U_STABLE int32_t U_EXPORT2
608uloc_getDisplayCountry(const char* locale,
609 const char* displayLocale,
610 UChar* country,
611 int32_t countryCapacity,
612 UErrorCode* status);
613
614
631U_STABLE int32_t U_EXPORT2
632uloc_getDisplayVariant(const char* locale,
633 const char* displayLocale,
634 UChar* variant,
635 int32_t variantCapacity,
636 UErrorCode* status);
637
678U_STABLE int32_t U_EXPORT2
679uloc_getDisplayKeyword(const char* keyword,
680 const char* displayLocale,
681 UChar* dest,
682 int32_t destCapacity,
683 UErrorCode* status);
704U_STABLE int32_t U_EXPORT2
705uloc_getDisplayKeywordValue( const char* locale,
706 const char* keyword,
707 const char* displayLocale,
708 UChar* dest,
709 int32_t destCapacity,
710 UErrorCode* status);
727U_STABLE int32_t U_EXPORT2
728uloc_getDisplayName(const char* localeID,
729 const char* inLocaleID,
730 UChar* result,
731 int32_t maxResultSize,
732 UErrorCode* err);
733
734
745U_STABLE const char* U_EXPORT2
747
754U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
755
767U_STABLE const char* const* U_EXPORT2
769
779U_STABLE const char* const* U_EXPORT2
781
795U_STABLE int32_t U_EXPORT2
796uloc_getParent(const char* localeID,
797 char* parent,
798 int32_t parentCapacity,
799 UErrorCode* err);
800
801
802
803
826U_STABLE int32_t U_EXPORT2
827uloc_getBaseName(const char* localeID,
828 char* name,
829 int32_t nameCapacity,
830 UErrorCode* err);
831
841U_STABLE UEnumeration* U_EXPORT2
842uloc_openKeywords(const char* localeID,
843 UErrorCode* status);
844
856U_STABLE int32_t U_EXPORT2
857uloc_getKeywordValue(const char* localeID,
858 const char* keywordName,
859 char* buffer, int32_t bufferCapacity,
860 UErrorCode* status);
861
862
885U_STABLE int32_t U_EXPORT2
886uloc_setKeywordValue(const char* keywordName,
887 const char* keywordValue,
888 char* buffer, int32_t bufferCapacity,
889 UErrorCode* status);
890
905U_STABLE UBool U_EXPORT2
906uloc_isRightToLeft(const char *locale);
907
913typedef enum {
914 ULOC_LAYOUT_LTR = 0, /* left-to-right. */
915 ULOC_LAYOUT_RTL = 1, /* right-to-left. */
916 ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */
917 ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */
918 ULOC_LAYOUT_UNKNOWN
920
929U_STABLE ULayoutType U_EXPORT2
930uloc_getCharacterOrientation(const char* localeId,
931 UErrorCode *status);
932
941U_STABLE ULayoutType U_EXPORT2
942uloc_getLineOrientation(const char* localeId,
943 UErrorCode *status);
944
951typedef enum {
952 ULOC_ACCEPT_FAILED = 0, /* No exact match was found. */
953 ULOC_ACCEPT_VALID = 1, /* An exact match was found. */
954 ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example,
955 Accept list contained 'ja_JP'
956 which matched available locale 'ja'. */
958
959
972U_STABLE int32_t U_EXPORT2
973uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
974 UAcceptResult *outResult,
975 const char *httpAcceptLanguage,
976 UEnumeration* availableLocales,
977 UErrorCode *status);
978
992U_STABLE int32_t U_EXPORT2
993uloc_acceptLanguage(char *result, int32_t resultAvailable,
994 UAcceptResult *outResult, const char **acceptList,
995 int32_t acceptListCount,
996 UEnumeration* availableLocales,
997 UErrorCode *status);
998
999
1012U_STABLE int32_t U_EXPORT2
1013uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
1014 UErrorCode *status);
1015
1016
1050U_STABLE int32_t U_EXPORT2
1051uloc_addLikelySubtags(const char* localeID,
1052 char* maximizedLocaleID,
1053 int32_t maximizedLocaleIDCapacity,
1054 UErrorCode* err);
1055
1056
1090U_STABLE int32_t U_EXPORT2
1091uloc_minimizeSubtags(const char* localeID,
1092 char* minimizedLocaleID,
1093 int32_t minimizedLocaleIDCapacity,
1094 UErrorCode* err);
1095
1119U_STABLE int32_t U_EXPORT2
1120uloc_forLanguageTag(const char* langtag,
1121 char* localeID,
1122 int32_t localeIDCapacity,
1123 int32_t* parsedLength,
1124 UErrorCode* err);
1125
1147U_STABLE int32_t U_EXPORT2
1148uloc_toLanguageTag(const char* localeID,
1149 char* langtag,
1150 int32_t langtagCapacity,
1151 UBool strict,
1152 UErrorCode* err);
1153
1175U_STABLE const char* U_EXPORT2
1176uloc_toUnicodeLocaleKey(const char* keyword);
1177
1206U_STABLE const char* U_EXPORT2
1207uloc_toUnicodeLocaleType(const char* keyword, const char* value);
1208
1221U_STABLE const char* U_EXPORT2
1222uloc_toLegacyKey(const char* keyword);
1223
1250U_STABLE const char* U_EXPORT2
1251uloc_toLegacyType(const char* keyword, const char* value);
1252
1253#endif /*_ULOC*/
C API: String Enumeration.
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:39
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...
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...
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.
uint32_t uloc_getLCID(const char *localeID)
Gets the Win32 LCID value for the specified locale.
const char * uloc_getAvailable(int32_t n)
Gets the specified locale from a list of all available locales.
int32_t uloc_getKeywordValue(const char *localeID, const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode *status)
Get the value for a keyword.
int32_t uloc_getName(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale.
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.
int32_t uloc_getCountry(const char *localeID, char *country, int32_t countryCapacity, UErrorCode *err)
Gets the country code for the specified locale.
ULayoutType uloc_getCharacterOrientation(const char *localeId, UErrorCode *status)
Get the layout character orientation for the specified locale.
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.
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.
const char *const * uloc_getISOCountries(void)
Gets a list of all available 2-letter country codes defined in ISO 639.
UAcceptResult
enums for the 'outResult' parameter return value
Definition: uloc.h:951
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.
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.
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.
void uloc_setDefault(const char *localeID, UErrorCode *status)
Sets ICU's default locale.
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.
const char * uloc_getISO3Language(const char *localeID)
Gets the ISO language code for the specified locale.
UEnumeration * uloc_openKeywords(const char *localeID, UErrorCode *status)
Gets an enumeration of keywords for the specified locale.
ULayoutType
enums for the return value for the character and line orientation functions.
Definition: uloc.h:913
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.
int32_t uloc_countAvailable(void)
Gets the size of the all available locale list.
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.
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.
int32_t uloc_getScript(const char *localeID, char *script, int32_t scriptCapacity, UErrorCode *err)
Gets the script code for the specified locale.
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...
int32_t uloc_getLanguage(const char *localeID, char *language, int32_t languageCapacity, UErrorCode *err)
Gets the language code for the specified locale.
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...
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.
UBool uloc_isRightToLeft(const char *locale)
Returns whether the locale's script is written right-to-left.
const char * uloc_toLegacyKey(const char *keyword)
Converts the specified keyword (BCP 47 Unicode locale extension key, or legacy key) to the legacy key...
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.
ULayoutType uloc_getLineOrientation(const char *localeId, UErrorCode *status)
Get the layout line orientation for the specified locale.
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.
const char * uloc_toUnicodeLocaleKey(const char *keyword)
Converts the specified keyword (legacy key, or BCP 47 Unicode locale extension key) to the equivalent...
int32_t uloc_getVariant(const char *localeID, char *variant, int32_t variantCapacity, UErrorCode *err)
Gets the variant code for the specified locale.
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...
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...
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:336
@ ULOC_ACTUAL_LOCALE
This is locale the data actually comes from.
Definition: uloc.h:340
@ ULOC_VALID_LOCALE
This is the most specific locale supported by ICU.
Definition: uloc.h:344
@ ULOC_REQUESTED_LOCALE
This is the requested locale.
Definition: uloc.h:350
const char * uloc_getISO3Country(const char *localeID)
Gets the ISO country code for the specified locale.
const char * uloc_getDefault(void)
Gets ICU's default locale.
int32_t uloc_canonicalize(const char *localeID, char *name, int32_t nameCapacity, UErrorCode *err)
Gets the full name for the specified locale.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:109
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476