ICU4C 79
Loading...
Searching...
No Matches
locid.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4******************************************************************************
5*
6* Copyright (C) 1996-2015, International Business Machines
7* Corporation and others. All Rights Reserved.
8*
9******************************************************************************
10*
11* File locid.h
12*
13* Created by: Helena Shih
14*
15* Modification History:
16*
17* Date Name Description
18* 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to
19* get and set it.
20* 04/02/97 aliu Made operator!= inline; fixed return value of getName().
21* 04/15/97 aliu Cleanup for AIX/Win32.
22* 04/24/97 aliu Numerous changes per code review.
23* 08/18/98 stephen Added tokenizeString(),changed getDisplayName()
24* 09/08/98 stephen Moved definition of kEmptyString for Mac Port
25* 11/09/99 weiv Added const char * getName() const;
26* 04/12/00 srl removing unicodestring api's and cached hash code
27* 08/10/01 grhoten Change the static Locales to accessor functions
28******************************************************************************
29*/
30
31#ifndef LOCID_H
32#define LOCID_H
33
34#include "unicode/utypes.h"
35
36#if U_SHOW_CPLUSPLUS_API
37
38#include <cstdint>
39#include <string_view>
40
41#include "unicode/bytestream.h"
43#include "unicode/strenum.h"
44#include "unicode/stringpiece.h"
45#include "unicode/uobject.h"
46#include "unicode/putil.h"
47#include "unicode/uloc.h"
48
53
54U_NAMESPACE_BEGIN
55
56// Forward Declarations
58
60class UnicodeString;
61
199public:
201 U_COMMON_API static const Locale& U_EXPORT2 getRoot();
203 U_COMMON_API static const Locale& U_EXPORT2 getEnglish();
205 U_COMMON_API static const Locale& U_EXPORT2 getFrench();
207 U_COMMON_API static const Locale& U_EXPORT2 getGerman();
209 U_COMMON_API static const Locale& U_EXPORT2 getItalian();
211 U_COMMON_API static const Locale& U_EXPORT2 getJapanese();
213 U_COMMON_API static const Locale& U_EXPORT2 getKorean();
215 U_COMMON_API static const Locale& U_EXPORT2 getChinese();
217 U_COMMON_API static const Locale& U_EXPORT2 getSimplifiedChinese();
219 U_COMMON_API static const Locale& U_EXPORT2 getTraditionalChinese();
220
222 U_COMMON_API static const Locale& U_EXPORT2 getFrance();
224 U_COMMON_API static const Locale& U_EXPORT2 getGermany();
226 U_COMMON_API static const Locale& U_EXPORT2 getItaly();
228 U_COMMON_API static const Locale& U_EXPORT2 getJapan();
230 U_COMMON_API static const Locale& U_EXPORT2 getKorea();
232 U_COMMON_API static const Locale& U_EXPORT2 getChina();
234 U_COMMON_API static const Locale& U_EXPORT2 getPRC();
236 U_COMMON_API static const Locale& U_EXPORT2 getTaiwan();
238 U_COMMON_API static const Locale& U_EXPORT2 getUK();
240 U_COMMON_API static const Locale& U_EXPORT2 getUS();
242 U_COMMON_API static const Locale& U_EXPORT2 getCanada();
244 U_COMMON_API static const Locale& U_EXPORT2 getCanadaFrench();
245
254
279 U_COMMON_API Locale(const char* language,
280 const char* country = nullptr,
281 const char* variant = nullptr,
282 const char* keywordsAndValues = nullptr);
283
291
299 U_COMMON_API Locale(Locale&& other) noexcept;
300
306
314 U_COMMON_API Locale& operator=(const Locale& other) U_LIFETIME_BOUND;
315
325 U_COMMON_API Locale& operator=(Locale&& other) noexcept U_LIFETIME_BOUND;
326
334 U_COMMON_API bool operator==(const Locale& other) const;
335
344 U_COMMON_API inline bool operator!=(const Locale& other) const;
345
358
359#ifndef U_HIDE_SYSTEM_API
375 U_COMMON_API static const Locale& U_EXPORT2 getDefault();
376
389 U_COMMON_API static void U_EXPORT2 setDefault(const Locale& newLocale, UErrorCode& success);
390#endif /* U_HIDE_SYSTEM_API */
391
414
428 U_COMMON_API void toLanguageTag(ByteSink& sink, UErrorCode& status) const;
429
440 template<typename StringClass>
441 inline StringClass toLanguageTag(UErrorCode& status) const;
442
452 U_COMMON_API static Locale U_EXPORT2 createFromName(const char* name);
453
454#ifndef U_HIDE_INTERNAL_API
457#endif /* U_HIDE_INTERNAL_API */
458
467 U_COMMON_API static Locale U_EXPORT2 createCanonical(const char* name);
468
474 U_COMMON_API const char* getLanguage() const U_LIFETIME_BOUND;
475
483 U_COMMON_API const char* getScript() const U_LIFETIME_BOUND;
484
490 U_COMMON_API const char* getCountry() const U_LIFETIME_BOUND;
491
497 U_COMMON_API const char* getVariant() const U_LIFETIME_BOUND;
498
507 U_COMMON_API const char* getName() const U_LIFETIME_BOUND;
508
516 U_COMMON_API const char* getBaseName() const U_LIFETIME_BOUND;
517
548
579
587
598
609
621 template<typename StringClass, typename OutputIterator>
622 inline void getKeywords(OutputIterator iterator, UErrorCode& status) const;
623
635 template<typename StringClass, typename OutputIterator>
636 inline void getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const;
637
654 U_COMMON_API int32_t getKeywordValue(const char* keywordName,
655 char* buffer,
656 int32_t bufferCapacity,
657 UErrorCode& status) const;
658
672 U_COMMON_API void getKeywordValue(StringPiece keywordName, ByteSink& sink, UErrorCode& status) const;
673
687 template<typename StringClass>
688 inline StringClass getKeywordValue(StringPiece keywordName, UErrorCode& status) const;
689
704 ByteSink& sink,
705 UErrorCode& status) const;
706
720 template<typename StringClass>
721 inline StringClass getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const;
722
742 U_COMMON_API void setKeywordValue(const char* keywordName,
743 const char* keywordValue,
744 UErrorCode& status) {
745 setKeywordValue(StringPiece{keywordName}, StringPiece{keywordValue}, status);
746 }
747
767 StringPiece keywordValue,
768 UErrorCode& status);
769
789 StringPiece keywordValue,
790 UErrorCode& status);
791
798 U_COMMON_API const char* getISO3Language() const;
799
805 U_COMMON_API const char* getISO3Country() const;
806
814 U_COMMON_API uint32_t getLCID() const;
815
830
840 U_COMMON_API UnicodeString& getDisplayLanguage(UnicodeString& dispLang U_LIFETIME_BOUND) const;
841
856 UnicodeString& dispLang U_LIFETIME_BOUND) const;
857
867 U_COMMON_API UnicodeString& getDisplayScript(UnicodeString& dispScript U_LIFETIME_BOUND) const;
868
884 UnicodeString& dispScript U_LIFETIME_BOUND) const;
885
896 getDisplayCountry(UnicodeString& dispCountry U_LIFETIME_BOUND) const;
897
913 getDisplayCountry(const Locale& displayLocale,
914 UnicodeString& dispCountry U_LIFETIME_BOUND) const;
915
924
934 UnicodeString& dispVar U_LIFETIME_BOUND) const;
935
948
962 UnicodeString& name U_LIFETIME_BOUND) const;
963
968 U_COMMON_API int32_t hashCode() const;
969
979
985 U_COMMON_API inline UBool isBogus() const;
986
995 U_COMMON_API static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
996
1005 U_COMMON_API static const char* const* U_EXPORT2 getISOCountries();
1006
1018 U_COMMON_API static const char* const* U_EXPORT2 getISOLanguages();
1019
1026
1032 U_COMMON_API virtual UClassID getDynamicClassID() const override;
1033
1038 class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ {
1039 public:
1041 virtual ~Iterator();
1042
1047 virtual UBool hasNext() const = 0;
1048
1053 virtual const Locale &next() = 0;
1054 };
1055
1060 template<typename Iter>
1061 class RangeIterator : public Iterator, public UMemory {
1062 public:
1072 RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {}
1073
1078 UBool hasNext() const override { return it_ != end_; }
1079
1084 const Locale &next() override { return *it_++; }
1085
1086 private:
1087 Iter it_;
1088 const Iter end_;
1089 };
1090
1096 template<typename Iter, typename Conv>
1097 class ConvertingIterator : public Iterator, public UMemory {
1098 public:
1109 ConvertingIterator(Iter begin, Iter end, Conv converter) :
1110 it_(begin), end_(end), converter_(converter) {}
1111
1116 UBool hasNext() const override { return it_ != end_; }
1117
1122 const Locale &next() override { return converter_(*it_++); }
1123
1124 private:
1125 Iter it_;
1126 const Iter end_;
1127 Conv converter_;
1128 };
1129
1130protected: /* only protected for testing purposes. DO NOT USE. */
1131#ifndef U_HIDE_INTERNAL_API
1136 U_COMMON_API void setFromPOSIXID(const char* posixID);
1145 U_COMMON_API void minimizeSubtags(bool favorScript, UErrorCode& status);
1146#endif /* U_HIDE_INTERNAL_API */
1147
1148private:
1156 Locale& init(const char* localeID, UBool canonicalize) U_LIFETIME_BOUND;
1157 Locale& init(StringPiece localeID, UBool canonicalize) U_LIFETIME_BOUND;
1158
1159 /*
1160 * Internal constructor to allow construction of a locale object with
1161 * NO side effects. (Default constructor tries to get
1162 * the default locale.)
1163 */
1164 enum ELocaleType : uint8_t {
1165 eBOGUS,
1166 eNEST,
1167 eHEAP,
1168 };
1169 Locale(ELocaleType);
1170
1174 static Locale* getLocaleCache();
1175
1176 union Payload;
1177 struct Nest;
1178 struct Heap;
1179
1183 struct Nest {
1184 static constexpr size_t SIZE = 32;
1185
1186 ELocaleType type = eNEST;
1187 char language[4];
1188 char script[5];
1189 char region[4];
1190 uint8_t variantBegin;
1191 char baseName[SIZE -
1192 sizeof type -
1193 sizeof language -
1194 sizeof script -
1195 sizeof region -
1196 sizeof variantBegin];
1197
1198 const char* getLanguage() const U_LIFETIME_BOUND { return language; }
1199 const char* getScript() const U_LIFETIME_BOUND { return script; }
1200 const char* getRegion() const U_LIFETIME_BOUND { return region; }
1201 const char* getVariant() const U_LIFETIME_BOUND {
1202 return variantBegin == 0 ? "" : getBaseName() + variantBegin;
1203 }
1204 const char* getBaseName() const U_LIFETIME_BOUND { return baseName; }
1205
1206 // Doesn't inherit from UMemory, shouldn't be heap allocated.
1207 static void* U_EXPORT2 operator new(size_t) noexcept = delete;
1208 static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
1209
1210 Nest() : language{'\0'}, script{'\0'}, region{'\0'}, variantBegin{0}, baseName{'\0'} {}
1211
1212 void init(std::string_view language,
1213 std::string_view script,
1214 std::string_view region,
1215 uint8_t variantBegin);
1216
1217 static bool fits(int32_t length,
1218 std::string_view language,
1219 std::string_view script,
1220 std::string_view region) {
1221 return length < static_cast<int32_t>(sizeof Nest::baseName) &&
1222 language.size() < sizeof Nest::language &&
1223 script.size() < sizeof Nest::script &&
1224 region.size() < sizeof Nest::region;
1225 }
1226
1227 private:
1228 friend union Payload;
1229 Nest(Heap&& heap, uint8_t variantBegin);
1230 };
1231 static_assert(sizeof(Nest) == Nest::SIZE);
1232
1236 struct Heap {
1237 struct Alloc;
1238
1239 ELocaleType type;
1240 char language[ULOC_LANG_CAPACITY];
1241 char script[ULOC_SCRIPT_CAPACITY];
1242 char region[ULOC_COUNTRY_CAPACITY];
1243 Alloc* ptr;
1244
1245 const char* getLanguage() const U_LIFETIME_BOUND { return language; }
1246 const char* getScript() const U_LIFETIME_BOUND { return script; }
1247 const char* getRegion() const U_LIFETIME_BOUND { return region; }
1248 const char* getVariant() const U_LIFETIME_BOUND;
1249 const char* getFullName() const U_LIFETIME_BOUND;
1250 const char* getBaseName() const U_LIFETIME_BOUND;
1251
1252 // Doesn't inherit from UMemory, shouldn't be heap allocated.
1253 static void* U_EXPORT2 operator new(size_t) noexcept = delete;
1254 static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
1255
1256 Heap(std::string_view language,
1257 std::string_view script,
1258 std::string_view region,
1259 int32_t variantBegin);
1260 ~Heap();
1261
1262 Heap& operator=(const Heap& other) U_LIFETIME_BOUND;
1263 Heap& operator=(Heap&& other) noexcept U_LIFETIME_BOUND;
1264 };
1265 static_assert(sizeof(Heap) <= sizeof(Nest));
1266
1271 union Payload {
1272 private:
1273 Nest nest;
1274 Heap heap;
1275 ELocaleType type;
1276
1277 void copy(const Payload& other);
1278 void move(Payload&& other) noexcept;
1279
1280 public:
1281 // Doesn't inherit from UMemory, shouldn't be heap allocated.
1282 static void* U_EXPORT2 operator new(size_t) noexcept = delete;
1283 static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
1284
1285 Payload() : type{eBOGUS} {}
1286 ~Payload();
1287
1288 Payload(const Payload& other);
1289 Payload(Payload&& other) noexcept;
1290
1291 Payload& operator=(const Payload& other) U_LIFETIME_BOUND;
1292 Payload& operator=(Payload&& other) noexcept U_LIFETIME_BOUND;
1293
1294 void setToBogus();
1295 bool isBogus() const { return type == eBOGUS; }
1296
1297 template <typename T, typename... Args> T& emplace(Args&&... args) U_LIFETIME_BOUND;
1298
1299 template <typename T> T* get() U_LIFETIME_BOUND;
1300
1301 template <typename BogusFn, typename NestFn, typename HeapFn, typename... Args>
1302 auto visit(BogusFn bogusFn, NestFn nestFn, HeapFn heapFn, Args... args) const;
1303 } payload;
1304
1313 template <const char* (Nest::*const NEST)() const,
1314 const char* (Heap::*const HEAP)() const>
1315 const char* getField() const U_LIFETIME_BOUND;
1316
1317 static const Locale &getLocale(int locid);
1318
1322 friend Locale *locale_set_default_internal(const char *, UErrorCode& status);
1323
1327};
1328
1329U_COMMON_API inline bool
1330Locale::operator!=(const Locale& other) const
1331{
1332 return !operator==(other);
1333}
1334
1335template<typename StringClass> inline StringClass
1337{
1338 if (U_FAILURE(status)) { return {}; }
1339 StringClass result;
1340 StringByteSink<StringClass> sink(&result);
1341 toLanguageTag(sink, status);
1342 return result;
1343}
1344
1345template<typename StringClass, typename OutputIterator> inline void
1346Locale::getKeywords(OutputIterator iterator, UErrorCode& status) const
1347{
1348 if (U_FAILURE(status)) { return; }
1350 if (U_FAILURE(status) || keys.isNull()) {
1351 return;
1352 }
1353 for (;;) {
1354 int32_t resultLength;
1355 const char* buffer = keys->next(&resultLength, status);
1356 if (U_FAILURE(status) || buffer == nullptr) {
1357 return;
1358 }
1359 *iterator++ = StringClass(buffer, resultLength);
1360 }
1361}
1362
1363template<typename StringClass, typename OutputIterator> inline void
1364Locale::getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const
1365{
1366 if (U_FAILURE(status)) { return; }
1368 if (U_FAILURE(status) || keys.isNull()) {
1369 return;
1370 }
1371 for (;;) {
1372 int32_t resultLength;
1373 const char* buffer = keys->next(&resultLength, status);
1374 if (U_FAILURE(status) || buffer == nullptr) {
1375 return;
1376 }
1377 *iterator++ = StringClass(buffer, resultLength);
1378 }
1379}
1380
1381template<typename StringClass> inline StringClass
1383{
1384 if (U_FAILURE(status)) { return {}; }
1385 StringClass result;
1386 StringByteSink<StringClass> sink(&result);
1387 getKeywordValue(keywordName, sink, status);
1388 return result;
1389}
1390
1391template<typename StringClass> inline StringClass
1393{
1394 if (U_FAILURE(status)) { return {}; }
1395 StringClass result;
1396 StringByteSink<StringClass> sink(&result);
1397 getUnicodeKeywordValue(keywordName, sink, status);
1398 return result;
1399}
1400
1401U_COMMON_API inline UBool
1403 return payload.isBogus();
1404}
1405
1406U_NAMESPACE_END
1407
1408#endif /* U_SHOW_CPLUSPLUS_API */
1409
1410#endif
C++ API: Interface for writing bytes, and implementation classes.
A ByteSink can be filled with bytes.
Definition bytestream.h:55
UBool isNull() const
nullptr check.
"Smart pointer" class, deletes objects via the standard C++ delete operator.
const Locale & next() override
Definition locid.h:1122
UBool hasNext() const override
Definition locid.h:1116
ConvertingIterator(Iter begin, Iter end, Conv converter)
Constructs an iterator from a begin/end range.
Definition locid.h:1109
A Locale iterator interface similar to a Java Iterator<Locale>.
Definition locid.h:1038
virtual UBool hasNext() const =0
virtual const Locale & next()=0
RangeIterator(Iter begin, Iter end)
Constructs an iterator from a begin/end range.
Definition locid.h:1072
UBool hasNext() const override
Definition locid.h:1078
const Locale & next() override
Definition locid.h:1084
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
static U_COMMON_API const Locale & getItaly()
Useful constant for this country/region.
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...
static U_COMMON_API const Locale & getFrance()
Useful constant for this country/region.
static U_COMMON_API Locale forLanguageTag(StringPiece tag, UErrorCode &status)
Returns a Locale for the specified BCP47 language tag string.
U_COMMON_API UBool isBogus() const
Gets the bogus state.
Definition locid.h:1402
U_COMMON_API int32_t getKeywordValue(const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const
Gets the value for a keyword.
static U_COMMON_API const Locale & getKorean()
Useful constant for this language.
U_COMMON_API void getUnicodeKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the Unicode value for a Unicode keyword.
U_COMMON_API Locale * clone() const
Clone this object.
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 U_COMMON_API const Locale & getChina()
Useful constant for this country/region.
U_COMMON_API void minimizeSubtags(bool favorScript, UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described.
static U_COMMON_API Locale createFromName(StringPiece name)
friend void locale_available_init()
U_COMMON_API void toLanguageTag(ByteSink &sink, UErrorCode &status) const
Returns a well-formed language tag for this Locale.
static U_COMMON_API const Locale & getSimplifiedChinese()
Useful constant for this language.
U_COMMON_API Locale & operator=(const Locale &other)
Replaces the entire contents of *this with the specified value.
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...
static U_COMMON_API const Locale & getGerman()
Useful constant for this language.
static U_COMMON_API const Locale & getKorea()
Useful constant for this country/region.
U_COMMON_API int32_t hashCode() const
Generates a hash code for the 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.
U_COMMON_API void minimizeSubtags(UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described in the following CLDR technical rep...
U_COMMON_API StringEnumeration * createKeywords(UErrorCode &status) const
Gets the list of keywords for the specified locale.
static U_COMMON_API const Locale & getCanada()
Useful constant for this country/region.
U_COMMON_API Locale()
Construct a default locale object, a Locale for the default locale ID.
static U_COMMON_API const Locale & getRoot()
Useful constant for the Root locale.
static U_COMMON_API UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
static U_COMMON_API const Locale & getTaiwan()
Useful constant for this country/region.
U_COMMON_API const char * getCountry() const
Returns the locale's ISO-3166 country code.
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 ...
U_COMMON_API const char * getLanguage() const
Returns the locale's ISO-639 language code.
U_COMMON_API void setFromPOSIXID(const char *posixID)
Set this from a single POSIX style locale string.
U_COMMON_API bool operator==(const Locale &other) const
Checks if two locale keys are the same.
static U_COMMON_API const Locale & getFrench()
Useful constant for this language.
U_COMMON_API const char * getScript() const
Returns the locale's ISO-15924 abbreviation script code.
void getUnicodeKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of Unicode keywords for this Locale.
Definition locid.h:1364
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 ...
static U_COMMON_API const Locale & getPRC()
Useful constant for this country/region.
static U_COMMON_API const char *const * getISOCountries()
Gets a list of all available 2-letter country codes defined in ISO 3166.
U_COMMON_API uint32_t getLCID() const
Returns the Windows LCID value corresponding to this locale.
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...
U_COMMON_API Locale(Locale &&other) noexcept
Move constructor; might leave source in bogus state.
static U_COMMON_API const Locale & getTraditionalChinese()
Useful constant for this language.
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...
U_COMMON_API Locale & operator=(Locale &&other) noexcept
Move assignment operator; might leave source in bogus state.
U_COMMON_API void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
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...
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 ...
static U_COMMON_API const Locale & getChinese()
Useful constant for this language.
static U_COMMON_API const Locale & getCanadaFrench()
Useful constant for this country/region.
static U_COMMON_API const char *const * getISOLanguages()
Returns a list of all unique language codes defined in ISO 639.
static U_COMMON_API const Locale & getDefault()
Common methods of getting the current default Locale.
U_COMMON_API void canonicalize(UErrorCode &status)
Canonicalize the locale ID of this object according to CLDR.
void getKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of keywords for this Locale.
Definition locid.h:1346
U_COMMON_API void setToBogus()
Sets the locale to bogus A bogus locale represents a non-existing locale associated with services tha...
U_COMMON_API const char * getName() const
Returns the programmatic name of the entire locale, with the language, country and variant separated ...
U_COMMON_API const char * getISO3Country() const
Fills in "name" with the locale's three-letter ISO-3166 country code.
static U_COMMON_API const Locale & getUK()
Useful constant for this country/region.
static U_COMMON_API const Locale & getJapanese()
Useful constant for this language.
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...
U_COMMON_API const char * getISO3Language() const
returns the locale's three-letter language code, as specified in ISO draft standard ISO-639-2.
U_COMMON_API const char * getVariant() const
Returns the locale's variant code.
U_COMMON_API Locale(const Locale &other)
Initializes a Locale object from another Locale object.
U_COMMON_API StringEnumeration * createUnicodeKeywords(UErrorCode &status) const
Gets the list of Unicode keywords for the specified locale.
static U_COMMON_API void setDefault(const Locale &newLocale, UErrorCode &success)
Sets the default.
U_COMMON_API UBool isRightToLeft() const
Returns whether this locale's script is written right-to-left.
virtual U_COMMON_API UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
U_COMMON_API void addLikelySubtags(UErrorCode &status)
Add the likely subtags for this Locale, per the algorithm described in the following CLDR technical r...
static U_COMMON_API const Locale * getAvailableLocales(int32_t &count)
Returns a list of all installed locales.
static U_COMMON_API const Locale & getItalian()
Useful constant for this language.
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 ...
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
U_COMMON_API const char * getBaseName() const
Returns the programmatic name of the entire locale as getName() would return, but without keywords.
static U_COMMON_API const Locale & getGermany()
Useful constant for this country/region.
virtual U_COMMON_API ~Locale()
Destructor.
static U_COMMON_API const Locale & getUS()
Useful constant for this country/region.
U_COMMON_API void setUnicodeKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the Unicode value for a Unicode keyword.
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 ...
static U_COMMON_API Locale createFromName(const char *name)
Creates a locale which has had minimal canonicalization as per uloc_getName().
static U_COMMON_API const Locale & getJapan()
Useful constant for this country/region.
static U_COMMON_API const Locale & getEnglish()
Useful constant for this language.
Implementation of ByteSink that writes to a "string".
Definition bytestream.h:293
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:61
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:61
UMemory is the common ICU base class.
Definition uobject.h:115
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
void locale_available_init()
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:880
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...
Definition uloc.h:271
#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
#define ULOC_LANG_CAPACITY
Useful constant for the maximum size of the language part of a locale ID.
Definition uloc.h:251
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition utypes.h:827
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315
#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