ICU 75.1 75.1
Loading...
Searching...
No Matches
Namespaces | Typedefs | Functions
ulocale.h File Reference

C API: Locale ID functionality similar to C++ class Locale. More...

#include "unicode/localpointer.h"
#include "unicode/uenum.h"
#include "unicode/utypes.h"

Go to the source code of this file.

Namespaces

namespace  icu
 File coll.h.
 

Typedefs

typedef struct ULocale ULocale
 C typedef for struct ULocale.
 

Functions

U_CAPI ULocaleulocale_openForLocaleID (const char *localeID, int32_t length, UErrorCode *err)
 Constructs an ULocale from the locale ID.
 
U_CAPI ULocaleulocale_openForLanguageTag (const char *tag, int32_t length, UErrorCode *err)
 Constructs an ULocale from the provided IETF BCP 47 language tag.
 
U_CAPI void ulocale_close (ULocale *locale)
 Close the locale and destroy it's internal states.
 
U_CAPI const char * ulocale_getLanguage (const ULocale *locale)
 Returns the locale's ISO-639 language code.
 
U_CAPI const char * ulocale_getScript (const ULocale *locale)
 Returns the locale's ISO-15924 abbreviation script code.
 
U_CAPI const char * ulocale_getRegion (const ULocale *locale)
 Returns the locale's ISO-3166 region code.
 
U_CAPI const char * ulocale_getVariant (const ULocale *locale)
 Returns the locale's variant code.
 
U_CAPI const char * ulocale_getLocaleID (const ULocale *locale)
 Returns the programmatic name of the entire locale, with the language, country and variant separated by underbars.
 
U_CAPI const char * ulocale_getBaseName (const ULocale *locale)
 Returns the programmatic name of the entire locale as ulocale_getLocaleID() would return, but without keywords.
 
U_CAPI bool ulocale_isBogus (const ULocale *locale)
 Gets the bogus state.
 
U_CAPI UEnumerationulocale_getKeywords (const ULocale *locale, UErrorCode *err)
 Gets the list of keywords for the specified locale.
 
U_CAPI UEnumerationulocale_getUnicodeKeywords (const ULocale *locale, UErrorCode *err)
 Gets the list of unicode keywords for the specified locale.
 
U_CAPI int32_t ulocale_getKeywordValue (const ULocale *locale, const char *keyword, int32_t keywordLength, char *valueBuffer, int32_t valueBufferCapacity, UErrorCode *err)
 Gets the value for a keyword.
 
U_CAPI int32_t ulocale_getUnicodeKeywordValue (const ULocale *locale, const char *keyword, int32_t keywordLength, char *valueBuffer, int32_t valueBufferCapacity, UErrorCode *err)
 Gets the Unicode value for a Unicode keyword.
 

Detailed Description

C API: Locale ID functionality similar to C++ class Locale.

Definition in file ulocale.h.

Typedef Documentation

◆ ULocale

typedef struct ULocale ULocale

C typedef for struct ULocale.

Draft:
This API may be changed in the future versions and was introduced in ICU 74

Definition at line 27 of file ulocale.h.

Function Documentation

◆ ulocale_close()

U_CAPI void ulocale_close ( ULocale locale)

Close the locale and destroy it's internal states.

Parameters
localethe locale
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getBaseName()

U_CAPI const char * ulocale_getBaseName ( const ULocale locale)

Returns the programmatic name of the entire locale as ulocale_getLocaleID() would return, but without keywords.

Parameters
localethe locale
Returns
A pointer to "base name".
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getKeywords()

U_CAPI UEnumeration * ulocale_getKeywords ( const ULocale locale,
UErrorCode err 
)

Gets the list of keywords for the specified locale.

Parameters
localethe locale
errthe error code
Returns
pointer to UEnumeration, or nullptr if there are no keywords. Client must call uenum_close() to dispose the returned value.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getKeywordValue()

U_CAPI int32_t ulocale_getKeywordValue ( const ULocale locale,
const char *  keyword,
int32_t  keywordLength,
char *  valueBuffer,
int32_t  valueBufferCapacity,
UErrorCode err 
)

Gets the value for a keyword.

This uses legacy keyword=value pairs, like "collation=phonebook".

Parameters
localethe locale
keywordthe keyword, a const char * pointer (need not be terminated when the length is non-negative)
keywordLengththe length of the keyword; if negative, then the keyword need to be null terminated.
valueBufferThe buffer to receive the value.
valueBufferCapacityThe capacity of receiving valueBuffer.
errthe error code
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getLanguage()

U_CAPI const char * ulocale_getLanguage ( const ULocale locale)

Returns the locale's ISO-639 language code.

Parameters
localethe locale
Returns
the language code of the locale.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getLocaleID()

U_CAPI const char * ulocale_getLocaleID ( const ULocale locale)

Returns the programmatic name of the entire locale, with the language, country and variant separated by underbars.

If a field is missing, up to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN", "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO"

Parameters
localethe locale
Returns
A pointer to "name".
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getRegion()

U_CAPI const char * ulocale_getRegion ( const ULocale locale)

Returns the locale's ISO-3166 region code.

Parameters
localethe locale
Returns
A pointer to the region.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getScript()

U_CAPI const char * ulocale_getScript ( const ULocale locale)

Returns the locale's ISO-15924 abbreviation script code.

Parameters
localethe locale
Returns
A pointer to the script.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getUnicodeKeywords()

U_CAPI UEnumeration * ulocale_getUnicodeKeywords ( const ULocale locale,
UErrorCode err 
)

Gets the list of unicode keywords for the specified locale.

Parameters
localethe locale
errthe error code
Returns
pointer to UEnumeration, or nullptr if there are no keywords. Client must call uenum_close() to dispose the returned value.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getUnicodeKeywordValue()

U_CAPI int32_t ulocale_getUnicodeKeywordValue ( const ULocale locale,
const char *  keyword,
int32_t  keywordLength,
char *  valueBuffer,
int32_t  valueBufferCapacity,
UErrorCode err 
)

Gets the Unicode value for a Unicode keyword.

This uses Unicode key-value pairs, like "co-phonebk".

Parameters
localethe locale
keywordthe Unicode keyword, a const char * pointer (need not be terminated when the length is non-negative)
keywordLengththe length of the Unicode keyword; if negative, then the keyword need to be null terminated.
valueBufferThe buffer to receive the Unicode value.
valueBufferCapacityThe capacity of receiving valueBuffer.
errthe error code
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_getVariant()

U_CAPI const char * ulocale_getVariant ( const ULocale locale)

Returns the locale's variant code.

Parameters
localethe locale
Returns
A pointer to the variant.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_isBogus()

U_CAPI bool ulocale_isBogus ( const ULocale locale)

Gets the bogus state.

Locale object can be bogus if it doesn't exist

Parameters
localethe locale
Returns
false if it is a real locale, true if it is a bogus locale
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_openForLanguageTag()

U_CAPI ULocale * ulocale_openForLanguageTag ( const char *  tag,
int32_t  length,
UErrorCode err 
)

Constructs an ULocale from the provided IETF BCP 47 language tag.

The created ULocale should be destroyed by calling ulocale_close();

Parameters
tagthe language tag, defined as IETF BCP 47 language tag, const char* pointer (need not be terminated when the length is non-negative)
lengththe length of the tag; if negative, then the tag need to be null terminated.
errthe error code
Returns
the locale.
Draft:
This API may be changed in the future versions and was introduced in ICU 74

◆ ulocale_openForLocaleID()

U_CAPI ULocale * ulocale_openForLocaleID ( const char *  localeID,
int32_t  length,
UErrorCode err 
)

Constructs an ULocale from the locale ID.

The created ULocale should be destroyed by calling ulocale_close();

Parameters
localeIDthe locale, a const char * pointer (need not be terminated when the length is non-negative)
lengththe length of the locale; if negative, then the locale need to be null terminated.
errthe error code
Returns
the locale.
Draft:
This API may be changed in the future versions and was introduced in ICU 74