#include <algorithm>
#include <optional>
#include <string_view>
#include "unicode/bytestream.h"
#include "unicode/errorcode.h"
#include "unicode/stringpiece.h"
#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "unicode/uloc.h"
#include "bytesinkutil.h"
#include "putilimp.h"
#include "ustr_imp.h"
#include "ulocimp.h"
#include "umutex.h"
#include "cstring.h"
#include "cmemory.h"
#include "locmap.h"
#include "uarrsort.h"
#include "uenumimp.h"
#include "uassert.h"
#include "charstr.h"
U_NAMESPACE_USE
U_CFUNC void locale_set_default(const char *id);
U_CFUNC const char *locale_get_default();
namespace {
constexpr const char* LANGUAGES[] = …;
constexpr const char* DEPRECATED_LANGUAGES[]= …;
constexpr const char* REPLACEMENT_LANGUAGES[]= …;
constexpr const char* LANGUAGES_3[] = …;
constexpr const char* COUNTRIES[] = …;
constexpr const char* DEPRECATED_COUNTRIES[] = …;
constexpr const char* REPLACEMENT_COUNTRIES[] = …;
constexpr const char* COUNTRIES_3[] = …;
CanonicalizationMap;
constexpr CanonicalizationMap CANONICALIZE_MAP[] = …;
int32_t getShortestSubtagLength(const char *localeID) { … }
inline bool _hasBCP47Extension(const char *id) { … }
inline bool UPRV_ISDIGIT(char c) { … }
inline bool UPRV_ISALPHANUM(char c) { … }
inline bool UPRV_OK_VALUE_PUNCTUATION(char c) { … }
}
#define ULOC_KEYWORD_BUFFER_LEN …
#define ULOC_MAX_NO_KEYWORDS …
U_CAPI const char * U_EXPORT2
locale_getKeywordsStart(const char *localeID) { … }
namespace {
CharString locale_canonKeywordName(std::string_view keywordName, UErrorCode& status)
{ … }
KeywordStruct;
int32_t U_CALLCONV
compareKeywordStructs(const void * , const void *left, const void *right) { … }
}
U_EXPORT CharString
ulocimp_getKeywords(const char* localeID,
char prev,
bool valuesToo,
UErrorCode& status)
{ … }
U_EXPORT void
ulocimp_getKeywords(const char* localeID,
char prev,
ByteSink& sink,
bool valuesToo,
UErrorCode& status)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getKeywordValue(const char* localeID,
const char* keywordName,
char* buffer, int32_t bufferCapacity,
UErrorCode* status)
{ … }
U_EXPORT CharString
ulocimp_getKeywordValue(const char* localeID,
std::string_view keywordName,
UErrorCode& status)
{ … }
U_EXPORT void
ulocimp_getKeywordValue(const char* localeID,
std::string_view keywordName,
icu::ByteSink& sink,
UErrorCode& status)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_setKeywordValue(const char* keywordName,
const char* keywordValue,
char* buffer, int32_t bufferCapacity,
UErrorCode* status)
{ … }
U_EXPORT void
ulocimp_setKeywordValue(std::string_view keywordName,
std::string_view keywordValue,
CharString& localeID,
UErrorCode& status)
{ … }
U_EXPORT int32_t
ulocimp_setKeywordValue(std::string_view keywords,
std::string_view keywordName,
std::string_view keywordValue,
ByteSink& sink,
UErrorCode& status)
{ … }
namespace {
inline bool _isPrefixLetter(char a) { … }
inline bool _isIDPrefix(const char *s) { … }
inline bool _isTerminator(char a) { … }
inline bool _isBCP47Extension(const char* p) { … }
std::optional<int16_t> _findIndex(const char* const* list, const char* key)
{ … }
}
U_CFUNC const char*
uloc_getCurrentCountryID(const char* oldID){ … }
U_CFUNC const char*
uloc_getCurrentLanguageID(const char* oldID){ … }
namespace {
void
_getLanguage(const char* localeID,
ByteSink* sink,
const char** pEnd,
UErrorCode& status) { … }
void
_getScript(const char* localeID,
ByteSink* sink,
const char** pEnd) { … }
void
_getRegion(const char* localeID,
ByteSink* sink,
const char** pEnd) { … }
void
_getVariant(const char* localeID,
char prev,
ByteSink* sink,
const char** pEnd,
bool needSeparator,
UErrorCode& status) { … }
}
U_EXPORT CharString
ulocimp_getLanguage(const char* localeID, UErrorCode& status) { … }
U_EXPORT CharString
ulocimp_getScript(const char* localeID, UErrorCode& status) { … }
U_EXPORT CharString
ulocimp_getRegion(const char* localeID, UErrorCode& status) { … }
U_EXPORT CharString
ulocimp_getVariant(const char* localeID, UErrorCode& status) { … }
U_EXPORT void
ulocimp_getSubtags(
const char* localeID,
CharString* language,
CharString* script,
CharString* region,
CharString* variant,
const char** pEnd,
UErrorCode& status) { … }
U_EXPORT void
ulocimp_getSubtags(
const char* localeID,
ByteSink* language,
ByteSink* script,
ByteSink* region,
ByteSink* variant,
const char** pEnd,
UErrorCode& status) { … }
UKeywordsContext;
U_CDECL_BEGIN
static void U_CALLCONV
uloc_kw_closeKeywords(UEnumeration *enumerator) { … }
static int32_t U_CALLCONV
uloc_kw_countKeywords(UEnumeration *en, UErrorCode * ) { … }
static const char * U_CALLCONV
uloc_kw_nextKeyword(UEnumeration* en,
int32_t* resultLength,
UErrorCode* ) { … }
static void U_CALLCONV
uloc_kw_resetKeywords(UEnumeration* en,
UErrorCode* ) { … }
U_CDECL_END
static const UEnumeration gKeywordsEnum = …;
U_CAPI UEnumeration* U_EXPORT2
uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCode* status)
{ … }
U_CAPI UEnumeration* U_EXPORT2
uloc_openKeywords(const char* localeID,
UErrorCode* status)
{ … }
#define _ULOC_STRIP_KEYWORDS …
#define _ULOC_CANONICALIZE …
namespace …
U_CAPI int32_t U_EXPORT2
uloc_getParent(const char* localeID,
char* parent,
int32_t parentCapacity,
UErrorCode* err)
{ … }
U_EXPORT CharString
ulocimp_getParent(const char* localeID,
UErrorCode& err)
{ … }
U_EXPORT void
ulocimp_getParent(const char* localeID,
icu::ByteSink& sink,
UErrorCode& err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getLanguage(const char* localeID,
char* language,
int32_t languageCapacity,
UErrorCode* err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getScript(const char* localeID,
char* script,
int32_t scriptCapacity,
UErrorCode* err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getCountry(const char* localeID,
char* country,
int32_t countryCapacity,
UErrorCode* err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getVariant(const char* localeID,
char* variant,
int32_t variantCapacity,
UErrorCode* err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getName(const char* localeID,
char* name,
int32_t nameCapacity,
UErrorCode* err)
{ … }
U_EXPORT CharString
ulocimp_getName(const char* localeID,
UErrorCode& err)
{ … }
U_EXPORT void
ulocimp_getName(const char* localeID,
ByteSink& sink,
UErrorCode& err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getBaseName(const char* localeID,
char* name,
int32_t nameCapacity,
UErrorCode* err)
{ … }
U_EXPORT CharString
ulocimp_getBaseName(const char* localeID,
UErrorCode& err)
{ … }
U_EXPORT void
ulocimp_getBaseName(const char* localeID,
ByteSink& sink,
UErrorCode& err)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_canonicalize(const char* localeID,
char* name,
int32_t nameCapacity,
UErrorCode* err)
{ … }
U_EXPORT CharString
ulocimp_canonicalize(const char* localeID,
UErrorCode& err)
{ … }
U_EXPORT void
ulocimp_canonicalize(const char* localeID,
ByteSink& sink,
UErrorCode& err)
{ … }
U_CAPI const char* U_EXPORT2
uloc_getISO3Language(const char* localeID)
{ … }
U_CAPI const char* U_EXPORT2
uloc_getISO3Country(const char* localeID)
{ … }
U_CAPI uint32_t U_EXPORT2
uloc_getLCID(const char* localeID)
{ … }
U_CAPI int32_t U_EXPORT2
uloc_getLocaleForLCID(uint32_t hostid, char *locale, int32_t localeCapacity,
UErrorCode *status)
{ … }
U_CAPI const char* U_EXPORT2
uloc_getDefault()
{ … }
U_CAPI void U_EXPORT2
uloc_setDefault(const char* newDefaultLocale,
UErrorCode* err)
{ … }
U_CAPI const char* const* U_EXPORT2
uloc_getISOLanguages()
{ … }
U_CAPI const char* const* U_EXPORT2
uloc_getISOCountries()
{ … }
U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleKey(const char* keyword)
{ … }
U_EXPORT std::optional<std::string_view>
ulocimp_toBcpKeyWithFallback(std::string_view keyword)
{ … }
U_CAPI const char* U_EXPORT2
uloc_toUnicodeLocaleType(const char* keyword, const char* value)
{ … }
U_EXPORT std::optional<std::string_view>
ulocimp_toBcpTypeWithFallback(std::string_view keyword, std::string_view value)
{ … }
namespace {
bool
isWellFormedLegacyKey(std::string_view key)
{ … }
bool
isWellFormedLegacyType(std::string_view legacyType)
{ … }
}
U_CAPI const char* U_EXPORT2
uloc_toLegacyKey(const char* keyword)
{ … }
U_EXPORT std::optional<std::string_view>
ulocimp_toLegacyKeyWithFallback(std::string_view keyword)
{ … }
U_CAPI const char* U_EXPORT2
uloc_toLegacyType(const char* keyword, const char* value)
{ … }
U_EXPORT std::optional<std::string_view>
ulocimp_toLegacyTypeWithFallback(std::string_view keyword, std::string_view value)
{ … }