36 #if U_SHOW_CPLUSPLUS_API
277 const char* country =
nullptr,
278 const char* variant =
nullptr,
279 const char* keywordsAndValues =
nullptr);
356 #ifndef U_HIDE_SYSTEM_API
438 template<
typename StringClass>
439 inline StringClass toLanguageTag(
UErrorCode& status)
const;
452 #ifndef U_HIDE_INTERNAL_API
472 inline const char * getLanguage( )
const;
481 inline const char * getScript( )
const;
488 inline const char * getCountry( )
const;
495 inline const char * getVariant( )
const;
505 inline const char * getName()
const;
619 template<
typename StringClass,
typename OutputIterator>
620 inline void getKeywords(OutputIterator iterator,
UErrorCode& status)
const;
633 template<
typename StringClass,
typename OutputIterator>
634 inline void getUnicodeKeywords(OutputIterator iterator,
UErrorCode& status)
const;
682 template<
typename StringClass>
713 template<
typename StringClass>
970 inline UBool isBogus()
const;
1045 template<
typename Iter>
1081 template<
typename Iter,
typename Conv>
1095 it_(begin), end_(end), converter_(converter) {}
1116 #ifndef U_HIDE_INTERNAL_API
1141 Locale& init(
const char* localeID,
UBool canonicalize);
1158 static Locale* getLocaleCache();
1163 int32_t variantBegin;
1172 static const Locale &getLocale(
int locid);
1192 template<
typename StringClass>
inline StringClass
1198 toLanguageTag(sink, status);
1203 Locale::getCountry()
const
1209 Locale::getLanguage()
const
1215 Locale::getScript()
const
1221 Locale::getVariant()
const
1223 return fIsBogus ?
"" : &baseName[variantBegin];
1227 Locale::getName()
const
1232 template<
typename StringClass,
typename OutputIterator>
inline void
1233 Locale::getKeywords(OutputIterator iterator,
UErrorCode& status)
const
1241 int32_t resultLength;
1242 const char* buffer = keys->next(&resultLength, status);
1243 if (
U_FAILURE(status) || buffer ==
nullptr) {
1246 *iterator++ = StringClass(buffer, resultLength);
1250 template<
typename StringClass,
typename OutputIterator>
inline void
1251 Locale::getUnicodeKeywords(OutputIterator iterator,
UErrorCode& status)
const
1259 int32_t resultLength;
1260 const char* buffer = keys->next(&resultLength, status);
1261 if (
U_FAILURE(status) || buffer ==
nullptr) {
1264 *iterator++ = StringClass(buffer, resultLength);
1268 template<
typename StringClass>
inline StringClass
1274 getKeywordValue(keywordName, sink, status);
1278 template<
typename StringClass>
inline StringClass
1284 getUnicodeKeywordValue(keywordName, sink, status);
1289 Locale::isBogus()
const {
C++ API: Interface for writing bytes, and implementation classes.
A ByteSink can be filled with bytes.
UBool isNull() const
nullptr check.
"Smart pointer" class, deletes objects via the standard C++ delete operator.
A generic Locale iterator implementation over Locale input iterators.
UBool hasNext() const override
ConvertingIterator(Iter begin, Iter end, Conv converter)
Constructs an iterator from a begin/end range.
const Locale & next() override
A Locale iterator interface similar to a Java Iterator<Locale>.
virtual UBool hasNext() const =0
virtual const Locale & next()=0
A generic Locale iterator implementation over Locale input iterators.
RangeIterator(Iter begin, Iter end)
Constructs an iterator from a begin/end range.
UBool hasNext() const override
const Locale & next() override
A Locale object represents a specific geographical, political, or cultural region.
static const Locale & getGerman()
Useful constant for this language.
void minimizeSubtags(UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described in the following CLDR technical rep...
static const Locale * getAvailableLocales(int32_t &count)
Returns a list of all installed locales.
void minimizeSubtags(bool favorScript, UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described.
static const char *const * getISOCountries()
Gets a list of all available 2-letter country codes defined in ISO 3166.
static Locale createFromName(const char *name)
Creates a locale which has had minimal canonicalization as per uloc_getName().
static const Locale & getChina()
Useful constant for this country/region.
friend void locale_available_init()
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.
static Locale createCanonical(const char *name)
Creates a locale from the given string after canonicalizing the string according to CLDR by calling u...
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...
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Locale()
Construct a default locale object, a Locale for the default locale ID.
Locale * clone() const
Clone this object.
void setKeywordValue(const char *keywordName, const char *keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
UnicodeString & getDisplayCountry(UnicodeString &dispCountry) const
Fills in "dispCountry" with the name of this locale's country in a format suitable for user display i...
static const Locale & getFrench()
Useful constant for this language.
Locale & operator=(Locale &&other) noexcept
Move assignment operator; might leave source in bogus state.
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 ...
Locale(const char *language, const char *country=nullptr, const char *variant=nullptr, const char *keywordsAndValues=nullptr)
Construct a locale from language, country, variant.
static const Locale & getChinese()
Useful constant for this language.
static const char *const * getISOLanguages()
Returns a list of all unique language codes defined in ISO 639.
static const Locale & getItalian()
Useful constant for this language.
const char * getISO3Country() const
Fills in "name" with the locale's three-letter ISO-3166 country code.
static const Locale & getUS()
Useful constant for this country/region.
static const Locale & getPRC()
Useful constant for this country/region.
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...
virtual ~Locale()
Destructor.
int32_t getKeywordValue(const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const
Gets the value for a keyword.
static void setDefault(const Locale &newLocale, UErrorCode &success)
Sets the default.
static const Locale & getTraditionalChinese()
Useful constant for this language.
static const Locale & getEnglish()
Useful constant for this language.
static Locale createFromName(StringPiece name)
bool operator==(const Locale &other) const
Checks if two locale keys are the same.
StringEnumeration * createKeywords(UErrorCode &status) const
Gets the list of keywords for the specified locale.
static const Locale & getCanadaFrench()
Useful constant for this country/region.
static const Locale & getItaly()
Useful constant for this country/region.
static const Locale & getRoot()
Useful constant for the Root locale.
static const Locale & getKorea()
Useful constant for this country/region.
UnicodeString & getDisplayLanguage(UnicodeString &dispLang) const
Fills in "dispLang" with the name of this locale's language in a format suitable for user display in ...
void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
void setUnicodeKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the Unicode value for a Unicode keyword.
StringEnumeration * createUnicodeKeywords(UErrorCode &status) const
Gets the list of Unicode keywords for the specified locale.
void toLanguageTag(ByteSink &sink, UErrorCode &status) const
Returns a well-formed language tag for this Locale.
const char * getBaseName() const
Returns the programmatic name of the entire locale as getName() would return, but without keywords.
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...
void setToBogus()
Sets the locale to bogus A bogus locale represents a non-existing locale associated with services tha...
void addLikelySubtags(UErrorCode &status)
Add the likely subtags for this Locale, per the algorithm described in the following CLDR technical r...
Locale & operator=(const Locale &other)
Replaces the entire contents of *this with the specified value.
static const Locale & getJapanese()
Useful constant for this language.
static const Locale & getUK()
Useful constant for this country/region.
void canonicalize(UErrorCode &status)
Canonicalize the locale ID of this object according to CLDR.
static const Locale & getKorean()
Useful constant for this language.
static const Locale & getJapan()
Useful constant for this country/region.
int32_t hashCode() const
Generates a hash code for the locale.
uint32_t getLCID() const
Returns the Windows LCID value corresponding to this locale.
Locale(const Locale &other)
Initializes a Locale object from another Locale object.
static const Locale & getGermany()
Useful constant for this country/region.
UnicodeString & getDisplayVariant(UnicodeString &dispVar) const
Fills in "dispVar" with the name of this locale's variant code in a format suitable for user display ...
const char * getISO3Language() const
returns the locale's three-letter language code, as specified in ISO draft standard ISO-639-2.
void getUnicodeKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the Unicode value for a Unicode keyword.
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...
UnicodeString & getDisplayScript(UnicodeString &dispScript) const
Fills in "dispScript" with the name of this locale's script in a format suitable for user display in ...
static const Locale & getSimplifiedChinese()
Useful constant for this language.
static const Locale & getCanada()
Useful constant for this country/region.
UBool isRightToLeft() const
Returns whether this locale's script is written right-to-left.
void setFromPOSIXID(const char *posixID)
Set this from a single POSIX style locale string.
static const Locale & getDefault()
Common methods of getting the current default Locale.
void getKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the value for a keyword.
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 ...
static const Locale & getFrance()
Useful constant for this country/region.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
static const Locale & getTaiwan()
Useful constant for this country/region.
static Locale forLanguageTag(StringPiece tag, UErrorCode &status)
Returns a Locale for the specified BCP47 language tag string.
Locale(Locale &&other) noexcept
Move constructor; might leave source in bogus state.
Implementation of ByteSink that writes to a "string".
Base class for 'pure' C++ implementations of uenum api.
A string-like object that points to a sized piece of memory.
UMemory is the common ICU base class.
UObject is the common ICU "boilerplate" class.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void locale_available_init()
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
C API: Platform Utilities.
C++ API: String Enumeration.
C++ API: StringPiece: Read-only byte string wrapper class.
C API: Locale ID functionality similar to C++ class Locale.
#define ULOC_SCRIPT_CAPACITY
Useful constant for the maximum size of the script part of a locale ID (including the terminating NUL...
#define ULOC_COUNTRY_CAPACITY
Useful constant for the maximum size of the country part of a locale ID (including the terminating NU...
#define ULOC_LANG_CAPACITY
Useful constant for the maximum size of the language part of a locale ID.
#define ULOC_FULLNAME_CAPACITY
Useful constant for the maximum size of the whole locale ID (including the terminating NULL and all k...
int8_t UBool
The ICU boolean type, a signed-byte integer.
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
#define U_FAILURE(x)
Does the error code indicate a failure?
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.