Loading...
Searching...
No Matches
locid.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) 1996-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*
* File locid.h
*
* Created by: Helena Shih
*
* Modification History:
*
* Date Name Description
* 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to
* get and set it.
* 04/02/97 aliu Made operator!= inline; fixed return value of getName().
* 04/15/97 aliu Cleanup for AIX/Win32.
* 04/24/97 aliu Numerous changes per code review.
* 08/18/98 stephen Added tokenizeString(),changed getDisplayName()
* 09/08/98 stephen Moved definition of kEmptyString for Mac Port
* 11/09/99 weiv Added const char * getName() const;
* 04/12/00 srl removing unicodestring api's and cached hash code
* 08/10/01 grhoten Change the static Locales to accessor functions
******************************************************************************
*/
#ifndef LOCID_H
#define LOCID_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include <cstdint>
#include <string_view>
#include "unicode/bytestream.h"
#include "unicode/localpointer.h"
#include "unicode/strenum.h"
#include "unicode/stringpiece.h"
#include "unicode/uobject.h"
#include "unicode/putil.h"
#include "unicode/uloc.h"
U_NAMESPACE_BEGIN
// Forward Declarations
void U_CALLCONV locale_available_init();
class StringEnumeration;
class UnicodeString;
class U_COMMON_API_CLASS Locale : public UObject {
public:
U_COMMON_API static const Locale& U_EXPORT2 getRoot();
U_COMMON_API static const Locale& U_EXPORT2 getEnglish();
U_COMMON_API static const Locale& U_EXPORT2 getFrench();
U_COMMON_API static const Locale& U_EXPORT2 getGerman();
U_COMMON_API static const Locale& U_EXPORT2 getItalian();
U_COMMON_API static const Locale& U_EXPORT2 getJapanese();
U_COMMON_API static const Locale& U_EXPORT2 getKorean();
U_COMMON_API static const Locale& U_EXPORT2 getChinese();
U_COMMON_API static const Locale& U_EXPORT2 getSimplifiedChinese();
U_COMMON_API static const Locale& U_EXPORT2 getTraditionalChinese();
U_COMMON_API static const Locale& U_EXPORT2 getFrance();
U_COMMON_API static const Locale& U_EXPORT2 getGermany();
U_COMMON_API static const Locale& U_EXPORT2 getItaly();
U_COMMON_API static const Locale& U_EXPORT2 getJapan();
U_COMMON_API static const Locale& U_EXPORT2 getKorea();
U_COMMON_API static const Locale& U_EXPORT2 getChina();
U_COMMON_API static const Locale& U_EXPORT2 getPRC();
U_COMMON_API static const Locale& U_EXPORT2 getTaiwan();
U_COMMON_API static const Locale& U_EXPORT2 getUK();
U_COMMON_API static const Locale& U_EXPORT2 getUS();
U_COMMON_API static const Locale& U_EXPORT2 getCanada();
U_COMMON_API static const Locale& U_EXPORT2 getCanadaFrench();
U_COMMON_API Locale();
U_COMMON_API Locale(const char* language,
const char* country = nullptr,
const char* variant = nullptr,
const char* keywordsAndValues = nullptr);
U_COMMON_API Locale(const Locale& other);
U_COMMON_API Locale(Locale&& other) noexcept;
U_COMMON_API virtual ~Locale();
U_COMMON_API Locale& operator=(const Locale& other);
U_COMMON_API Locale& operator=(Locale&& other) noexcept;
U_COMMON_API bool operator==(const Locale& other) const;
U_COMMON_API inline bool operator!=(const Locale& other) const;
U_COMMON_API Locale* clone() const;
#ifndef U_HIDE_SYSTEM_API
U_COMMON_API static const Locale& U_EXPORT2 getDefault();
U_COMMON_API static void U_EXPORT2 setDefault(const Locale& newLocale, UErrorCode& success);
#endif /* U_HIDE_SYSTEM_API */
U_COMMON_API static Locale U_EXPORT2 forLanguageTag(StringPiece tag, UErrorCode& status);
U_COMMON_API void toLanguageTag(ByteSink& sink, UErrorCode& status) const;
template<typename StringClass>
inline StringClass toLanguageTag(UErrorCode& status) const;
U_COMMON_API static Locale U_EXPORT2 createFromName(const char* name);
#ifndef U_HIDE_INTERNAL_API
U_COMMON_API static Locale U_EXPORT2 createFromName(StringPiece name);
#endif /* U_HIDE_INTERNAL_API */
U_COMMON_API static Locale U_EXPORT2 createCanonical(const char* name);
U_COMMON_API const char* getLanguage() const;
U_COMMON_API const char* getScript() const;
U_COMMON_API const char* getCountry() const;
U_COMMON_API const char* getVariant() const;
U_COMMON_API const char* getName() const;
U_COMMON_API const char* getBaseName() const;
U_COMMON_API void addLikelySubtags(UErrorCode& status);
U_COMMON_API void minimizeSubtags(UErrorCode& status);
U_COMMON_API void canonicalize(UErrorCode& status);
U_COMMON_API StringEnumeration* createKeywords(UErrorCode& status) const;
U_COMMON_API StringEnumeration* createUnicodeKeywords(UErrorCode& status) const;
template<typename StringClass, typename OutputIterator>
inline void getKeywords(OutputIterator iterator, UErrorCode& status) const;
template<typename StringClass, typename OutputIterator>
inline void getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const;
U_COMMON_API int32_t getKeywordValue(const char* keywordName,
char* buffer,
int32_t bufferCapacity,
UErrorCode& status) const;
U_COMMON_API void getKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const;
template<typename StringClass>
inline StringClass getKeywordValue(StringPiece keywordName, UErrorCode& status) const;
U_COMMON_API void getUnicodeKeywordValue(StringPiece keywordName,
ByteSink& sink,
UErrorCode& status) const;
template<typename StringClass>
inline StringClass getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const;
U_COMMON_API void setKeywordValue(const char* keywordName,
const char* keywordValue,
UErrorCode& status) {
setKeywordValue(StringPiece{keywordName}, StringPiece{keywordValue}, status);
}
U_COMMON_API void setKeywordValue(StringPiece keywordName,
StringPiece keywordValue,
UErrorCode& status);
U_COMMON_API void setUnicodeKeywordValue(StringPiece keywordName,
StringPiece keywordValue,
UErrorCode& status);
U_COMMON_API const char* getISO3Language() const;
U_COMMON_API const char* getISO3Country() const;
U_COMMON_API uint32_t getLCID() const;
U_COMMON_API UBool isRightToLeft() const;
U_COMMON_API UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
U_COMMON_API UnicodeString& getDisplayLanguage(const Locale& displayLocale,
UnicodeString& dispLang) const;
U_COMMON_API UnicodeString& getDisplayScript(UnicodeString& dispScript) const;
U_COMMON_API UnicodeString& getDisplayScript(const Locale& displayLocale,
UnicodeString& dispScript) const;
U_COMMON_API UnicodeString& getDisplayCountry(UnicodeString& dispCountry) const;
U_COMMON_API UnicodeString& getDisplayCountry(const Locale& displayLocale,
UnicodeString& dispCountry) const;
U_COMMON_API UnicodeString& getDisplayVariant(UnicodeString& dispVar) const;
U_COMMON_API UnicodeString& getDisplayVariant(const Locale& displayLocale,
UnicodeString& dispVar) const;
U_COMMON_API UnicodeString& getDisplayName(UnicodeString& name) const;
U_COMMON_API UnicodeString& getDisplayName(const Locale& displayLocale, UnicodeString& name) const;
U_COMMON_API int32_t hashCode() const;
U_COMMON_API void setToBogus();
U_COMMON_API inline UBool isBogus() const;
U_COMMON_API static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
U_COMMON_API static const char* const* U_EXPORT2 getISOCountries();
U_COMMON_API static const char* const* U_EXPORT2 getISOLanguages();
U_COMMON_API static UClassID U_EXPORT2 getStaticClassID();
U_COMMON_API virtual UClassID getDynamicClassID() const override;
class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ {
public:
virtual ~Iterator();
virtual UBool hasNext() const = 0;
virtual const Locale &next() = 0;
};
template<typename Iter>
class RangeIterator : public Iterator, public UMemory {
public:
RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {}
UBool hasNext() const override { return it_ != end_; }
const Locale &next() override { return *it_++; }
private:
Iter it_;
const Iter end_;
};
template<typename Iter, typename Conv>
class ConvertingIterator : public Iterator, public UMemory {
public:
ConvertingIterator(Iter begin, Iter end, Conv converter) :
it_(begin), end_(end), converter_(converter) {}
UBool hasNext() const override { return it_ != end_; }
const Locale &next() override { return converter_(*it_++); }
private:
Iter it_;
const Iter end_;
Conv converter_;
};
protected: /* only protected for testing purposes. DO NOT USE. */
#ifndef U_HIDE_INTERNAL_API
U_COMMON_API void setFromPOSIXID(const char* posixID);
U_COMMON_API void minimizeSubtags(bool favorScript, UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
private:
Locale& init(const char* localeID, UBool canonicalize);
Locale& init(StringPiece localeID, UBool canonicalize);
/*
* Internal constructor to allow construction of a locale object with
* NO side effects. (Default constructor tries to get
* the default locale.)
*/
enum ELocaleType : uint8_t {
eBOGUS,
eNEST,
eHEAP,
};
Locale(ELocaleType);
static Locale* getLocaleCache();
union Payload;
struct Nest;
struct Heap;
struct Nest {
static constexpr size_t SIZE = 32;
ELocaleType type = eNEST;
char language[4];
char script[5];
char region[4];
uint8_t variantBegin;
char baseName[SIZE -
sizeof type -
sizeof language -
sizeof script -
sizeof region -
sizeof variantBegin];
const char* getLanguage() const { return language; }
const char* getScript() const { return script; }
const char* getRegion() const { return region; }
const char* getVariant() const { return variantBegin == 0 ? "" : getBaseName() + variantBegin; }
const char* getBaseName() const { return baseName; }
// Doesn't inherit from UMemory, shouldn't be heap allocated.
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
Nest() : language{'\0'}, script{'\0'}, region{'\0'}, variantBegin{0}, baseName{'\0'} {}
void init(std::string_view language,
std::string_view script,
std::string_view region,
uint8_t variantBegin);
static bool fits(int32_t length,
std::string_view language,
std::string_view script,
std::string_view region) {
return length < static_cast<int32_t>(sizeof Nest::baseName) &&
language.size() < sizeof Nest::language &&
script.size() < sizeof Nest::script &&
region.size() < sizeof Nest::region;
}
private:
friend union Payload;
Nest(Heap&& heap, uint8_t variantBegin);
};
static_assert(sizeof(Nest) == Nest::SIZE);
struct Heap {
struct Alloc;
ELocaleType type;
char language[ULOC_LANG_CAPACITY];
char script[ULOC_SCRIPT_CAPACITY];
char region[ULOC_COUNTRY_CAPACITY];
Alloc* ptr;
const char* getLanguage() const { return language; }
const char* getScript() const { return script; }
const char* getRegion() const { return region; }
const char* getVariant() const;
const char* getFullName() const;
const char* getBaseName() const;
// Doesn't inherit from UMemory, shouldn't be heap allocated.
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
Heap(std::string_view language,
std::string_view script,
std::string_view region,
int32_t variantBegin);
~Heap();
Heap& operator=(const Heap& other);
Heap& operator=(Heap&& other) noexcept;
};
static_assert(sizeof(Heap) <= sizeof(Nest));
union Payload {
private:
Nest nest;
Heap heap;
ELocaleType type;
void copy(const Payload& other);
void move(Payload&& other) noexcept;
public:
// Doesn't inherit from UMemory, shouldn't be heap allocated.
static void* U_EXPORT2 operator new(size_t) noexcept = delete;
static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
Payload() : type{eBOGUS} {}
~Payload();
Payload(const Payload& other);
Payload(Payload&& other) noexcept;
Payload& operator=(const Payload& other);
Payload& operator=(Payload&& other) noexcept;
void setToBogus();
bool isBogus() const { return type == eBOGUS; }
template <typename T, typename... Args> T& emplace(Args&&... args);
template <typename T> T* get();
template <typename BogusFn, typename NestFn, typename HeapFn, typename... Args>
auto visit(BogusFn bogusFn, NestFn nestFn, HeapFn heapFn, Args... args) const;
} payload;
template <const char* (Nest::*const NEST)() const,
const char* (Heap::*const HEAP)() const>
const char* getField() const;
static const Locale &getLocale(int locid);
friend Locale *locale_set_default_internal(const char *, UErrorCode& status);
friend void U_CALLCONV locale_available_init();
};
U_COMMON_API inline bool
Locale::operator!=(const Locale& other) const
{
return !operator==(other);
}
template<typename StringClass> inline StringClass
Locale::toLanguageTag(UErrorCode& status) const
{
if (U_FAILURE(status)) { return {}; }
StringClass result;
StringByteSink<StringClass> sink(&result);
toLanguageTag(sink, status);
return result;
}
template<typename StringClass, typename OutputIterator> inline void
Locale::getKeywords(OutputIterator iterator, UErrorCode& status) const
{
if (U_FAILURE(status)) { return; }
LocalPointer<StringEnumeration> keys(createKeywords(status));
if (U_FAILURE(status) || keys.isNull()) {
return;
}
for (;;) {
int32_t resultLength;
const char* buffer = keys->next(&resultLength, status);
if (U_FAILURE(status) || buffer == nullptr) {
return;
}
*iterator++ = StringClass(buffer, resultLength);
}
}
template<typename StringClass, typename OutputIterator> inline void
Locale::getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const
{
if (U_FAILURE(status)) { return; }
LocalPointer<StringEnumeration> keys(createUnicodeKeywords(status));
if (U_FAILURE(status) || keys.isNull()) {
return;
}
for (;;) {
int32_t resultLength;
const char* buffer = keys->next(&resultLength, status);
if (U_FAILURE(status) || buffer == nullptr) {
return;
}
*iterator++ = StringClass(buffer, resultLength);
}
}
template<typename StringClass> inline StringClass
Locale::getKeywordValue(StringPiece keywordName, UErrorCode& status) const
{
if (U_FAILURE(status)) { return {}; }
StringClass result;
StringByteSink<StringClass> sink(&result);
getKeywordValue(keywordName, sink, status);
return result;
}
template<typename StringClass> inline StringClass
Locale::getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const
{
if (U_FAILURE(status)) { return {}; }
StringClass result;
StringByteSink<StringClass> sink(&result);
getUnicodeKeywordValue(keywordName, sink, status);
return result;
}
U_COMMON_API inline UBool
Locale::isBogus() const {
return payload.isBogus();
}
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
bytestream.h
C++ API: Interface for writing bytes, and implementation classes.
icu::ByteSink
A ByteSink can be filled with bytes.
Definition bytestream.h:55
icu::LocalPointerBase::isNull
UBool isNull() const
nullptr check.
Definition localpointer.h:92
icu::LocalPointer
"Smart pointer" class, deletes objects via the standard C++ delete operator.
Definition localpointer.h:189
icu::Locale::ConvertingIterator::next
const Locale & next() override
Definition locid.h:1119
icu::Locale::ConvertingIterator::hasNext
UBool hasNext() const override
Definition locid.h:1113
icu::Locale::ConvertingIterator::ConvertingIterator
ConvertingIterator(Iter begin, Iter end, Conv converter)
Constructs an iterator from a begin/end range.
Definition locid.h:1106
icu::Locale::Iterator
A Locale iterator interface similar to a Java Iterator<Locale>.
Definition locid.h:1035
icu::Locale::Iterator::hasNext
virtual UBool hasNext() const =0
icu::Locale::Iterator::next
virtual const Locale & next()=0
icu::Locale::Iterator::~Iterator
virtual ~Iterator()
icu::Locale::RangeIterator::RangeIterator
RangeIterator(Iter begin, Iter end)
Constructs an iterator from a begin/end range.
Definition locid.h:1069
icu::Locale::RangeIterator::hasNext
UBool hasNext() const override
Definition locid.h:1075
icu::Locale::RangeIterator::next
const Locale & next() override
Definition locid.h:1081
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
icu::Locale::getItaly
static U_COMMON_API const Locale & getItaly()
Useful constant for this country/region.
icu::Locale::getDisplayCountry
U_COMMON_API UnicodeString & getDisplayCountry(UnicodeString &dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display i...
icu::Locale::getFrance
static U_COMMON_API const Locale & getFrance()
Useful constant for this country/region.
icu::Locale::forLanguageTag
static U_COMMON_API Locale forLanguageTag(StringPiece tag, UErrorCode &status)
Returns a Locale for the specified BCP47 language tag string.
icu::Locale::isBogus
U_COMMON_API UBool isBogus() const
Gets the bogus state.
Definition locid.h:1397
icu::Locale::getKeywordValue
U_COMMON_API int32_t getKeywordValue(const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const
Gets the value for a keyword.
icu::Locale::getKorean
static U_COMMON_API const Locale & getKorean()
Useful constant for this language.
icu::Locale::getUnicodeKeywordValue
U_COMMON_API void getUnicodeKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the Unicode value for a Unicode keyword.
icu::Locale::clone
U_COMMON_API Locale * clone() const
Clone this object.
icu::Locale::locale_set_default_internal
friend Locale * locale_set_default_internal(const char *, UErrorCode &status)
A friend to allow the default locale to be set by either the C or C++ API.
icu::Locale::getChina
static U_COMMON_API const Locale & getChina()
Useful constant for this country/region.
icu::Locale::minimizeSubtags
U_COMMON_API void minimizeSubtags(bool favorScript, UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described.
icu::Locale::createFromName
static U_COMMON_API Locale createFromName(StringPiece name)
icu::Locale::locale_available_init
friend void locale_available_init()
icu::Locale::toLanguageTag
U_COMMON_API void toLanguageTag(ByteSink &sink, UErrorCode &status) const
Returns a well-formed language tag for this Locale.
icu::Locale::getSimplifiedChinese
static U_COMMON_API const Locale & getSimplifiedChinese()
Useful constant for this language.
icu::Locale::operator=
U_COMMON_API Locale & operator=(const Locale &other)
Replaces the entire contents of *this with the specified value.
icu::Locale::createCanonical
static U_COMMON_API Locale createCanonical(const char *name)
Creates a locale from the given string after canonicalizing the string according to CLDR by calling u...
icu::Locale::getGerman
static U_COMMON_API const Locale & getGerman()
Useful constant for this language.
icu::Locale::getKorea
static U_COMMON_API const Locale & getKorea()
Useful constant for this country/region.
icu::Locale::hashCode
U_COMMON_API int32_t hashCode() const
Generates a hash code for the locale.
icu::Locale::Locale
U_COMMON_API Locale(const char *language, const char *country=nullptr, const char *variant=nullptr, const char *keywordsAndValues=nullptr)
Construct a locale from language, country, variant.
icu::Locale::minimizeSubtags
U_COMMON_API void minimizeSubtags(UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described in the following CLDR technical rep...
icu::Locale::createKeywords
U_COMMON_API StringEnumeration * createKeywords(UErrorCode &status) const
Gets the list of keywords for the specified locale.
icu::Locale::getCanada
static U_COMMON_API const Locale & getCanada()
Useful constant for this country/region.
icu::Locale::Locale
U_COMMON_API Locale()
Construct a default locale object, a Locale for the default locale ID.
icu::Locale::getRoot
static U_COMMON_API const Locale & getRoot()
Useful constant for the Root locale.
icu::Locale::getStaticClassID
static U_COMMON_API UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::Locale::getTaiwan
static U_COMMON_API const Locale & getTaiwan()
Useful constant for this country/region.
icu::Locale::getCountry
U_COMMON_API const char * getCountry() const
Returns the locale's ISO-3166 country code.
icu::Locale::getDisplayVariant
U_COMMON_API UnicodeString & getDisplayVariant(const Locale &displayLocale, UnicodeString &dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display ...
icu::Locale::getLanguage
U_COMMON_API const char * getLanguage() const
Returns the locale's ISO-639 language code.
icu::Locale::setFromPOSIXID
U_COMMON_API void setFromPOSIXID(const char *posixID)
Set this from a single POSIX style locale string.
icu::Locale::getKeywordValue
U_COMMON_API void getKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the value for a keyword.
icu::Locale::operator==
U_COMMON_API bool operator==(const Locale &other) const
Checks if two locale keys are the same.
icu::Locale::getFrench
static U_COMMON_API const Locale & getFrench()
Useful constant for this language.
icu::Locale::getScript
U_COMMON_API const char * getScript() const
Returns the locale's ISO-15924 abbreviation script code.
icu::Locale::getUnicodeKeywords
void getUnicodeKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of Unicode keywords for this Locale.
Definition locid.h:1359
icu::Locale::getDisplayVariant
U_COMMON_API UnicodeString & getDisplayVariant(UnicodeString &dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display ...
icu::Locale::getPRC
static U_COMMON_API const Locale & getPRC()
Useful constant for this country/region.
icu::Locale::getISOCountries
static U_COMMON_API const char *const * getISOCountries()
Gets a list of all available 2-letter country codes defined in ISO 3166.
icu::Locale::getLCID
U_COMMON_API uint32_t getLCID() const
Returns the Windows LCID value corresponding to this locale.
icu::Locale::getDisplayName
U_COMMON_API UnicodeString & getDisplayName(UnicodeString &name) const
Fills in "name" with the name of this locale in a format suitable for user display in the default loc...
icu::Locale::Locale
U_COMMON_API Locale(Locale &&other) noexcept
Move constructor; might leave source in bogus state.
icu::Locale::getTraditionalChinese
static U_COMMON_API const Locale & getTraditionalChinese()
Useful constant for this language.
icu::Locale::getDisplayCountry
U_COMMON_API UnicodeString & getDisplayCountry(const Locale &displayLocale, UnicodeString &dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display i...
icu::Locale::operator=
U_COMMON_API Locale & operator=(Locale &&other) noexcept
Move assignment operator; might leave source in bogus state.
icu::Locale::setKeywordValue
U_COMMON_API void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
icu::Locale::getDisplayName
U_COMMON_API UnicodeString & getDisplayName(const Locale &displayLocale, UnicodeString &name) const
Fills in "name" with the name of this locale in a format suitable for user display in the locale spec...
icu::Locale::getDisplayScript
U_COMMON_API UnicodeString & getDisplayScript(UnicodeString &dispScript) const
Fills in "dispScript" with the name of this locale's script in a format suitable for user display in ...
icu::Locale::getChinese
static U_COMMON_API const Locale & getChinese()
Useful constant for this language.
icu::Locale::getCanadaFrench
static U_COMMON_API const Locale & getCanadaFrench()
Useful constant for this country/region.
icu::Locale::getISOLanguages
static U_COMMON_API const char *const * getISOLanguages()
Returns a list of all unique language codes defined in ISO 639.
icu::Locale::getDefault
static U_COMMON_API const Locale & getDefault()
Common methods of getting the current default Locale.
icu::Locale::canonicalize
U_COMMON_API void canonicalize(UErrorCode &status)
Canonicalize the locale ID of this object according to CLDR.
icu::Locale::getKeywords
void getKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of keywords for this Locale.
Definition locid.h:1341
icu::Locale::setToBogus
U_COMMON_API void setToBogus()
Sets the locale to bogus A bogus locale represents a non-existing locale associated with services tha...
icu::Locale::getName
U_COMMON_API const char * getName() const
Returns the programmatic name of the entire locale, with the language, country and variant separated ...
icu::Locale::getISO3Country
U_COMMON_API const char * getISO3Country() const
Fills in "name" with the locale's three-letter ISO-3166 country code.
icu::Locale::getUK
static U_COMMON_API const Locale & getUK()
Useful constant for this country/region.
icu::Locale::getJapanese
static U_COMMON_API const Locale & getJapanese()
Useful constant for this language.
icu::Locale::getDisplayScript
U_COMMON_API UnicodeString & getDisplayScript(const Locale &displayLocale, UnicodeString &dispScript) const
Fills in "dispScript" with the name of this locale's country in a format suitable for user display in...
icu::Locale::getISO3Language
U_COMMON_API const char * getISO3Language() const
returns the locale's three-letter language code, as specified in ISO draft standard ISO-639-2.
icu::Locale::getVariant
U_COMMON_API const char * getVariant() const
Returns the locale's variant code.
icu::Locale::Locale
U_COMMON_API Locale(const Locale &other)
Initializes a Locale object from another Locale object.
icu::Locale::createUnicodeKeywords
U_COMMON_API StringEnumeration * createUnicodeKeywords(UErrorCode &status) const
Gets the list of Unicode keywords for the specified locale.
icu::Locale::setDefault
static U_COMMON_API void setDefault(const Locale &newLocale, UErrorCode &success)
Sets the default.
icu::Locale::isRightToLeft
U_COMMON_API UBool isRightToLeft() const
Returns whether this locale's script is written right-to-left.
icu::Locale::getDynamicClassID
virtual U_COMMON_API UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::Locale::addLikelySubtags
U_COMMON_API void addLikelySubtags(UErrorCode &status)
Add the likely subtags for this Locale, per the algorithm described in the following CLDR technical r...
icu::Locale::getAvailableLocales
static U_COMMON_API const Locale * getAvailableLocales(int32_t &count)
Returns a list of all installed locales.
icu::Locale::getItalian
static U_COMMON_API const Locale & getItalian()
Useful constant for this language.
icu::Locale::getDisplayLanguage
U_COMMON_API UnicodeString & getDisplayLanguage(UnicodeString &dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in ...
icu::Locale::setKeywordValue
U_COMMON_API void setKeywordValue(const char *keywordName, const char *keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
Definition locid.h:742
icu::Locale::getBaseName
U_COMMON_API const char * getBaseName() const
Returns the programmatic name of the entire locale as getName() would return, but without keywords.
icu::Locale::getGermany
static U_COMMON_API const Locale & getGermany()
Useful constant for this country/region.
icu::Locale::~Locale
virtual U_COMMON_API ~Locale()
Destructor.
icu::Locale::getUS
static U_COMMON_API const Locale & getUS()
Useful constant for this country/region.
icu::Locale::setUnicodeKeywordValue
U_COMMON_API void setUnicodeKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the Unicode value for a Unicode keyword.
icu::Locale::getDisplayLanguage
U_COMMON_API UnicodeString & getDisplayLanguage(const Locale &displayLocale, UnicodeString &dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in ...
icu::Locale::createFromName
static U_COMMON_API Locale createFromName(const char *name)
Creates a locale which has had minimal canonicalization as per uloc_getName().
icu::Locale::getJapan
static U_COMMON_API const Locale & getJapan()
Useful constant for this country/region.
icu::Locale::getEnglish
static U_COMMON_API const Locale & getEnglish()
Useful constant for this language.
icu::StringByteSink
Implementation of ByteSink that writes to a "string".
Definition bytestream.h:291
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:61
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:61
icu::UMemory
UMemory is the common ICU base class.
Definition uobject.h:115
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
icu::operator==
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::locale_available_init
void locale_available_init()
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition stringpiece.h:346
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:836
putil.h
C API: Platform Utilities.
strenum.h
C++ API: String Enumeration.
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
uloc.h
C API: Locale ID functionality similar to C++ class Locale.
ULOC_SCRIPT_CAPACITY
#define ULOC_SCRIPT_CAPACITY
Useful constant for the maximum size of the script part of a locale ID (including the terminating NUL...
Definition uloc.h:271
ULOC_COUNTRY_CAPACITY
#define ULOC_COUNTRY_CAPACITY
Useful constant for the maximum size of the country part of a locale ID (including the terminating NU...
Definition uloc.h:258
ULOC_LANG_CAPACITY
#define ULOC_LANG_CAPACITY
Useful constant for the maximum size of the language part of a locale ID.
Definition uloc.h:251
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
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
U_FAILURE
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition utypes.h:827
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315
U_COMMON_API_CLASS
#define U_COMMON_API_CLASS
Set to export library symbols from inside the common library, and to import them from outside,...
Definition utypes.h:456