ICU 78.3 78.3

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"
42 #include "unicode/localpointer.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
54 U_NAMESPACE_BEGIN
55
56 // Forward Declarations
57 void U_CALLCONV locale_available_init();
59 class StringEnumeration;
60 class UnicodeString;
61
198 class U_COMMON_API_CLASS Locale : public UObject {
199 public:
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
253 U_COMMON_API Locale();
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
290 U_COMMON_API Locale(const Locale& other);
291
299 U_COMMON_API Locale(Locale&& other) noexcept;
300
305 U_COMMON_API virtual ~Locale();
306
314 U_COMMON_API Locale& operator=(const Locale& other);
315
325 U_COMMON_API Locale& operator=(Locale&& other) noexcept;
326
334 U_COMMON_API bool operator==(const Locale& other) const;
335
344 U_COMMON_API inline bool operator!=(const Locale& other) const;
345
357 U_COMMON_API Locale* clone() const;
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
413 U_COMMON_API static Locale U_EXPORT2 forLanguageTag(StringPiece tag, UErrorCode& status);
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
456 U_COMMON_API static Locale U_EXPORT2 createFromName(StringPiece name);
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;
475
483 U_COMMON_API const char* getScript() const;
484
490 U_COMMON_API const char* getCountry() const;
491
497 U_COMMON_API const char* getVariant() const;
498
507 U_COMMON_API const char* getName() const;
508
516 U_COMMON_API const char* getBaseName() const;
517
547 U_COMMON_API void addLikelySubtags(UErrorCode& status);
548
578 U_COMMON_API void minimizeSubtags(UErrorCode& status);
579
586 U_COMMON_API void canonicalize(UErrorCode& status);
587
597 U_COMMON_API StringEnumeration* createKeywords(UErrorCode& status) const;
598
608 U_COMMON_API StringEnumeration* createUnicodeKeywords(UErrorCode& status) const;
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
703 U_COMMON_API void getUnicodeKeywordValue(StringPiece keywordName,
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
766 U_COMMON_API void setKeywordValue(StringPiece keywordName,
767 StringPiece keywordValue,
768 UErrorCode& status);
769
788 U_COMMON_API void setUnicodeKeywordValue(StringPiece keywordName,
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
829 U_COMMON_API UBool isRightToLeft() const;
830
840 U_COMMON_API UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
841
855 U_COMMON_API UnicodeString& getDisplayLanguage(const Locale& displayLocale,
856 UnicodeString& dispLang) const;
857
867 U_COMMON_API UnicodeString& getDisplayScript(UnicodeString& dispScript) const;
868
883 U_COMMON_API UnicodeString& getDisplayScript(const Locale& displayLocale,
884 UnicodeString& dispScript) const;
885
895 U_COMMON_API UnicodeString& getDisplayCountry(UnicodeString& dispCountry) const;
896
911 U_COMMON_API UnicodeString& getDisplayCountry(const Locale& displayLocale,
912 UnicodeString& dispCountry) const;
913
921 U_COMMON_API UnicodeString& getDisplayVariant(UnicodeString& dispVar) const;
922
931 U_COMMON_API UnicodeString& getDisplayVariant(const Locale& displayLocale,
932 UnicodeString& dispVar) const;
933
945 U_COMMON_API UnicodeString& getDisplayName(UnicodeString& name) const;
946
959 U_COMMON_API UnicodeString& getDisplayName(const Locale& displayLocale, UnicodeString& name) const;
960
965 U_COMMON_API int32_t hashCode() const;
966
975 U_COMMON_API void setToBogus();
976
982 U_COMMON_API inline UBool isBogus() const;
983
992 U_COMMON_API static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
993
1002 U_COMMON_API static const char* const* U_EXPORT2 getISOCountries();
1003
1015 U_COMMON_API static const char* const* U_EXPORT2 getISOLanguages();
1016
1022 U_COMMON_API static UClassID U_EXPORT2 getStaticClassID();
1023
1029 U_COMMON_API virtual UClassID getDynamicClassID() const override;
1030
1035 class U_COMMON_API Iterator /* not : public UObject because this is an interface/mixin class */ {
1036 public:
1038 virtual ~Iterator();
1039
1044 virtual UBool hasNext() const = 0;
1045
1050 virtual const Locale &next() = 0;
1051 };
1052
1057 template<typename Iter>
1058 class RangeIterator : public Iterator, public UMemory {
1059 public:
1069 RangeIterator(Iter begin, Iter end) : it_(begin), end_(end) {}
1070
1075 UBool hasNext() const override { return it_ != end_; }
1076
1081 const Locale &next() override { return *it_++; }
1082
1083 private:
1084 Iter it_;
1085 const Iter end_;
1086 };
1087
1093 template<typename Iter, typename Conv>
1094 class ConvertingIterator : public Iterator, public UMemory {
1095 public:
1106 ConvertingIterator(Iter begin, Iter end, Conv converter) :
1107 it_(begin), end_(end), converter_(converter) {}
1108
1113 UBool hasNext() const override { return it_ != end_; }
1114
1119 const Locale &next() override { return converter_(*it_++); }
1120
1121 private:
1122 Iter it_;
1123 const Iter end_;
1124 Conv converter_;
1125 };
1126
1127 protected: /* only protected for testing purposes. DO NOT USE. */
1128 #ifndef U_HIDE_INTERNAL_API
1133 U_COMMON_API void setFromPOSIXID(const char* posixID);
1142 U_COMMON_API void minimizeSubtags(bool favorScript, UErrorCode& status);
1143 #endif /* U_HIDE_INTERNAL_API */
1144
1145 private:
1153 Locale& init(const char* localeID, UBool canonicalize);
1154 Locale& init(StringPiece localeID, UBool canonicalize);
1155
1156 /*
1157 * Internal constructor to allow construction of a locale object with
1158 * NO side effects. (Default constructor tries to get
1159 * the default locale.)
1160 */
1161 enum ELocaleType : uint8_t {
1162 eBOGUS,
1163 eNEST,
1164 eHEAP,
1165 };
1166 Locale(ELocaleType);
1167
1171 static Locale* getLocaleCache();
1172
1173 union Payload;
1174 struct Nest;
1175 struct Heap;
1176
1180 struct Nest {
1181 static constexpr size_t SIZE = 32;
1182
1183 ELocaleType type = eNEST;
1184 char language[4];
1185 char script[5];
1186 char region[4];
1187 uint8_t variantBegin;
1188 char baseName[SIZE -
1189 sizeof type -
1190 sizeof language -
1191 sizeof script -
1192 sizeof region -
1193 sizeof variantBegin];
1194
1195 const char* getLanguage() const { return language; }
1196 const char* getScript() const { return script; }
1197 const char* getRegion() const { return region; }
1198 const char* getVariant() const { return variantBegin == 0 ? "" : getBaseName() + variantBegin; }
1199 const char* getBaseName() const { return baseName; }
1200
1201 // Doesn't inherit from UMemory, shouldn't be heap allocated.
1202 static void* U_EXPORT2 operator new(size_t) noexcept = delete;
1203 static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
1204
1205 Nest() : language{'\0'}, script{'\0'}, region{'\0'}, variantBegin{0}, baseName{'\0'} {}
1206
1207 void init(std::string_view language,
1208 std::string_view script,
1209 std::string_view region,
1210 uint8_t variantBegin);
1211
1212 static bool fits(int32_t length,
1213 std::string_view language,
1214 std::string_view script,
1215 std::string_view region) {
1216 return length < static_cast<int32_t>(sizeof Nest::baseName) &&
1217 language.size() < sizeof Nest::language &&
1218 script.size() < sizeof Nest::script &&
1219 region.size() < sizeof Nest::region;
1220 }
1221
1222 private:
1223 friend union Payload;
1224 Nest(Heap&& heap, uint8_t variantBegin);
1225 };
1226 static_assert(sizeof(Nest) == Nest::SIZE);
1227
1231 struct Heap {
1232 struct Alloc;
1233
1234 ELocaleType type;
1235 char language[ULOC_LANG_CAPACITY];
1236 char script[ULOC_SCRIPT_CAPACITY];
1237 char region[ULOC_COUNTRY_CAPACITY];
1238 Alloc* ptr;
1239
1240 const char* getLanguage() const { return language; }
1241 const char* getScript() const { return script; }
1242 const char* getRegion() const { return region; }
1243 const char* getVariant() const;
1244 const char* getFullName() const;
1245 const char* getBaseName() const;
1246
1247 // Doesn't inherit from UMemory, shouldn't be heap allocated.
1248 static void* U_EXPORT2 operator new(size_t) noexcept = delete;
1249 static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
1250
1251 Heap(std::string_view language,
1252 std::string_view script,
1253 std::string_view region,
1254 int32_t variantBegin);
1255 ~Heap();
1256
1257 Heap& operator=(const Heap& other);
1258 Heap& operator=(Heap&& other) noexcept;
1259 };
1260 static_assert(sizeof(Heap) <= sizeof(Nest));
1261
1266 union Payload {
1267 private:
1268 Nest nest;
1269 Heap heap;
1270 ELocaleType type;
1271
1272 void copy(const Payload& other);
1273 void move(Payload&& other) noexcept;
1274
1275 public:
1276 // Doesn't inherit from UMemory, shouldn't be heap allocated.
1277 static void* U_EXPORT2 operator new(size_t) noexcept = delete;
1278 static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
1279
1280 Payload() : type{eBOGUS} {}
1281 ~Payload();
1282
1283 Payload(const Payload& other);
1284 Payload(Payload&& other) noexcept;
1285
1286 Payload& operator=(const Payload& other);
1287 Payload& operator=(Payload&& other) noexcept;
1288
1289 void setToBogus();
1290 bool isBogus() const { return type == eBOGUS; }
1291
1292 template <typename T, typename... Args> T& emplace(Args&&... args);
1293
1294 template <typename T> T* get();
1295
1296 template <typename BogusFn, typename NestFn, typename HeapFn, typename... Args>
1297 auto visit(BogusFn bogusFn, NestFn nestFn, HeapFn heapFn, Args... args) const;
1298 } payload;
1299
1308 template <const char* (Nest::*const NEST)() const,
1309 const char* (Heap::*const HEAP)() const>
1310 const char* getField() const;
1311
1312 static const Locale &getLocale(int locid);
1313
1317 friend Locale *locale_set_default_internal(const char *, UErrorCode& status);
1318
1321 friend void U_CALLCONV locale_available_init();
1322 };
1323
1324 U_COMMON_API inline bool
1325 Locale::operator!=(const Locale& other) const
1326 {
1327 return !operator==(other);
1328 }
1329
1330 template<typename StringClass> inline StringClass
1331 Locale::toLanguageTag(UErrorCode& status) const
1332 {
1333 if (U_FAILURE(status)) { return {}; }
1334 StringClass result;
1335 StringByteSink<StringClass> sink(&result);
1336 toLanguageTag(sink, status);
1337 return result;
1338 }
1339
1340 template<typename StringClass, typename OutputIterator> inline void
1341 Locale::getKeywords(OutputIterator iterator, UErrorCode& status) const
1342 {
1343 if (U_FAILURE(status)) { return; }
1344 LocalPointer<StringEnumeration> keys(createKeywords(status));
1345 if (U_FAILURE(status) || keys.isNull()) {
1346 return;
1347 }
1348 for (;;) {
1349 int32_t resultLength;
1350 const char* buffer = keys->next(&resultLength, status);
1351 if (U_FAILURE(status) || buffer == nullptr) {
1352 return;
1353 }
1354 *iterator++ = StringClass(buffer, resultLength);
1355 }
1356 }
1357
1358 template<typename StringClass, typename OutputIterator> inline void
1359 Locale::getUnicodeKeywords(OutputIterator iterator, UErrorCode& status) const
1360 {
1361 if (U_FAILURE(status)) { return; }
1362 LocalPointer<StringEnumeration> keys(createUnicodeKeywords(status));
1363 if (U_FAILURE(status) || keys.isNull()) {
1364 return;
1365 }
1366 for (;;) {
1367 int32_t resultLength;
1368 const char* buffer = keys->next(&resultLength, status);
1369 if (U_FAILURE(status) || buffer == nullptr) {
1370 return;
1371 }
1372 *iterator++ = StringClass(buffer, resultLength);
1373 }
1374 }
1375
1376 template<typename StringClass> inline StringClass
1377 Locale::getKeywordValue(StringPiece keywordName, UErrorCode& status) const
1378 {
1379 if (U_FAILURE(status)) { return {}; }
1380 StringClass result;
1381 StringByteSink<StringClass> sink(&result);
1382 getKeywordValue(keywordName, sink, status);
1383 return result;
1384 }
1385
1386 template<typename StringClass> inline StringClass
1387 Locale::getUnicodeKeywordValue(StringPiece keywordName, UErrorCode& status) const
1388 {
1389 if (U_FAILURE(status)) { return {}; }
1390 StringClass result;
1391 StringByteSink<StringClass> sink(&result);
1392 getUnicodeKeywordValue(keywordName, sink, status);
1393 return result;
1394 }
1395
1396 U_COMMON_API inline UBool
1397 Locale::isBogus() const {
1398 return payload.isBogus();
1399 }
1400
1401 U_NAMESPACE_END
1402
1403 #endif /* U_SHOW_CPLUSPLUS_API */
1404
1405 #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
A generic Locale iterator implementation over Locale input iterators.
Definition: locid.h:1094
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::ConvertingIterator::next
const Locale & next() override
Definition: locid.h:1119
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::~Iterator
virtual ~Iterator()
icu::Locale::Iterator::next
virtual const Locale & next()=0
icu::Locale::RangeIterator
A generic Locale iterator implementation over Locale input iterators.
Definition: locid.h:1058
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::getJapan
static U_COMMON_API const Locale & getJapan()
Useful constant for this country/region.
icu::Locale::getLanguage
U_COMMON_API const char * getLanguage() const
Returns the locale's ISO-639 language code.
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::getUS
static U_COMMON_API const Locale & getUS()
Useful constant for this country/region.
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::getUnicodeKeywordValue
U_COMMON_API void getUnicodeKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the Unicode value for a Unicode keyword.
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::minimizeSubtags
U_COMMON_API void minimizeSubtags(bool favorScript, UErrorCode &status)
Minimize the subtags for this Locale, per the algorithm described.
icu::Locale::clone
U_COMMON_API Locale * clone() const
Clone this object.
icu::Locale::getCanadaFrench
static U_COMMON_API const Locale & getCanadaFrench()
Useful constant for this country/region.
icu::Locale::createFromName
static U_COMMON_API Locale createFromName(StringPiece name)
icu::Locale::toLanguageTag
U_COMMON_API void toLanguageTag(ByteSink &sink, UErrorCode &status) const
Returns a well-formed language tag for this Locale.
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::getJapanese
static U_COMMON_API const Locale & getJapanese()
Useful constant for this language.
icu::Locale::getItalian
static U_COMMON_API const Locale & getItalian()
Useful constant for this language.
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::createUnicodeKeywords
U_COMMON_API StringEnumeration * createUnicodeKeywords(UErrorCode &status) const
Gets the list of Unicode keywords for the specified locale.
icu::Locale::getItaly
static U_COMMON_API const Locale & getItaly()
Useful constant for this country/region.
icu::Locale::getPRC
static U_COMMON_API const Locale & getPRC()
Useful constant for this country/region.
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::getISOLanguages
static U_COMMON_API const char *const * getISOLanguages()
Returns a list of all unique language codes defined in ISO 639.
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::getChinese
static U_COMMON_API const Locale & getChinese()
Useful constant for this language.
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::getFrance
static U_COMMON_API const Locale & getFrance()
Useful constant for this country/region.
icu::Locale::getGerman
static U_COMMON_API const Locale & getGerman()
Useful constant for this language.
icu::Locale::getAvailableLocales
static U_COMMON_API const Locale * getAvailableLocales(int32_t &count)
Returns a list of all installed locales.
icu::Locale::Locale
U_COMMON_API Locale()
Construct a default locale object, a Locale for the default locale ID.
icu::Locale::getStaticClassID
static U_COMMON_API UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
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::getISO3Country
U_COMMON_API const char * getISO3Country() const
Fills in "name" with the locale's three-letter ISO-3166 country code.
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::getFrench
static U_COMMON_API const Locale & getFrench()
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::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::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::getUnicodeKeywords
void getUnicodeKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of Unicode keywords for this Locale.
Definition: locid.h:1359
icu::Locale::operator=
U_COMMON_API Locale & operator=(const Locale &other)
Replaces the entire contents of *this with the specified value.
icu::Locale::getEnglish
static U_COMMON_API const Locale & getEnglish()
Useful constant for this language.
icu::Locale::getRoot
static U_COMMON_API const Locale & getRoot()
Useful constant for the Root locale.
icu::Locale::getUK
static U_COMMON_API const Locale & getUK()
Useful constant for this country/region.
icu::Locale::getLCID
U_COMMON_API uint32_t getLCID() const
Returns the Windows LCID value corresponding to this locale.
icu::Locale::createKeywords
U_COMMON_API StringEnumeration * createKeywords(UErrorCode &status) const
Gets the list of keywords for the specified locale.
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::Locale
U_COMMON_API Locale(Locale &&other) noexcept
Move constructor; might leave source in bogus state.
icu::Locale::getCanada
static U_COMMON_API const Locale & getCanada()
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::getGermany
static U_COMMON_API const Locale & getGermany()
Useful constant for this country/region.
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::setKeywordValue
U_COMMON_API void setKeywordValue(StringPiece keywordName, StringPiece keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
icu::Locale::getDefault
static U_COMMON_API const Locale & getDefault()
Common methods of getting the current default Locale.
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::getTraditionalChinese
static U_COMMON_API const Locale & getTraditionalChinese()
Useful constant for this language.
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::operator=
U_COMMON_API Locale & operator=(Locale &&other) noexcept
Move assignment operator; might leave source in bogus state.
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::getChina
static U_COMMON_API const Locale & getChina()
Useful constant for this country/region.
icu::Locale::getSimplifiedChinese
static U_COMMON_API const Locale & getSimplifiedChinese()
Useful constant for this language.
icu::Locale::Locale
U_COMMON_API Locale(const Locale &other)
Initializes a Locale object from another Locale object.
icu::Locale::setDefault
static U_COMMON_API void setDefault(const Locale &newLocale, UErrorCode &success)
Sets the default.
icu::Locale::getKorea
static U_COMMON_API const Locale & getKorea()
Useful constant for this country/region.
icu::Locale::getTaiwan
static U_COMMON_API const Locale & getTaiwan()
Useful constant for this country/region.
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::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::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::~Locale
virtual U_COMMON_API ~Locale()
Destructor.
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::getCountry
U_COMMON_API const char * getCountry() const
Returns the locale's ISO-3166 country code.
icu::Locale::getScript
U_COMMON_API const char * getScript() const
Returns the locale's ISO-15924 abbreviation script code.
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::getVariant
U_COMMON_API const char * getVariant() const
Returns the locale's variant code.
icu::Locale::getKorean
static U_COMMON_API const Locale & getKorean()
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:837
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