#include <utility>
#include "unicode/bytestream.h"
#include "unicode/utypes.h"
#include "unicode/ures.h"
#include "unicode/localpointer.h"
#include "unicode/putil.h"
#include "unicode/uenum.h"
#include "unicode/uloc.h"
#include "bytesinkutil.h"
#include "charstr.h"
#include "cmemory.h"
#include "cstring.h"
#include "putilimp.h"
#include "uinvchar.h"
#include "ulocimp.h"
#include "uassert.h"
namespace {
VariantListEntry;
struct AttributeListEntry : public icu::UMemory { … };
struct ExtensionListEntry : public icu::UMemory { … };
#define MAXEXTLANG …
ULanguageTag;
#define MINLEN …
#define SEP …
#define PRIVATEUSE …
#define LDMLEXT …
#define LOCALE_SEP …
#define LOCALE_EXT_SEP …
#define LOCALE_KEYWORD_SEP …
#define LOCALE_KEY_TYPE_SEP …
constexpr auto ISALPHA = …;
inline bool ISNUMERIC(char c) { … }
constexpr char EMPTY[] = …;
constexpr char LANG_UND[] = …;
constexpr char PRIVATEUSE_KEY[] = …;
constexpr char _POSIX[] = …;
constexpr char POSIX_KEY[] = …;
constexpr char POSIX_VALUE[] = …;
constexpr char LOCALE_ATTRIBUTE_KEY[] = …;
constexpr char PRIVUSE_VARIANT_PREFIX[] = …;
constexpr char LOCALE_TYPE_YES[] = …;
#define LANG_UND_LEN …
constexpr const char* LEGACY[] = …;
constexpr const char* REDUNDANT[] = …;
constexpr char DEPRECATEDLANGS[][4] = …;
constexpr char DEPRECATEDREGIONS[][3] = …;
ULanguageTag*
ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode& status);
void
ultag_close(ULanguageTag* langtag);
const char*
ultag_getLanguage(const ULanguageTag* langtag);
#if 0
const char*
ultag_getJDKLanguage(const ULanguageTag* langtag);
#endif
const char*
ultag_getExtlang(const ULanguageTag* langtag, int32_t idx);
int32_t
ultag_getExtlangSize(const ULanguageTag* langtag);
const char*
ultag_getScript(const ULanguageTag* langtag);
const char*
ultag_getRegion(const ULanguageTag* langtag);
const char*
ultag_getVariant(const ULanguageTag* langtag, int32_t idx);
int32_t
ultag_getVariantsSize(const ULanguageTag* langtag);
const char*
ultag_getExtensionKey(const ULanguageTag* langtag, int32_t idx);
const char*
ultag_getExtensionValue(const ULanguageTag* langtag, int32_t idx);
int32_t
ultag_getExtensionsSize(const ULanguageTag* langtag);
const char*
ultag_getPrivateUse(const ULanguageTag* langtag);
#if 0
const char*
ultag_getLegacy(const ULanguageTag* langtag);
#endif
}
U_NAMESPACE_BEGIN
namespace {
bool
_isAlphaString(const char* s, int32_t len) { … }
bool
_isNumericString(const char* s, int32_t len) { … }
bool
_isAlphaNumericString(const char* s, int32_t len) { … }
bool
_isAlphaNumericStringLimitedLength(const char* s, int32_t len, int32_t min, int32_t max) { … }
}
bool
ultag_isLanguageSubtag(const char* s, int32_t len) { … }
namespace {
bool
_isExtlangSubtag(const char* s, int32_t len) { … }
}
bool
ultag_isScriptSubtag(const char* s, int32_t len) { … }
bool
ultag_isRegionSubtag(const char* s, int32_t len) { … }
namespace {
bool
_isVariantSubtag(const char* s, int32_t len) { … }
bool
_isSepListOf(bool (*test)(const char*, int32_t), const char* s, int32_t len) { … }
}
bool
ultag_isVariantSubtags(const char* s, int32_t len) { … }
namespace {
bool
_isPrivateuseVariantSubtag(const char* s, int32_t len) { … }
bool
_isExtensionSingleton(const char* s, int32_t len) { … }
bool
_isExtensionSubtag(const char* s, int32_t len) { … }
}
bool
ultag_isExtensionSubtags(const char* s, int32_t len) { … }
namespace {
bool
_isPrivateuseValueSubtag(const char* s, int32_t len) { … }
}
bool
ultag_isPrivateuseValueSubtags(const char* s, int32_t len) { … }
bool
ultag_isUnicodeLocaleAttribute(const char* s, int32_t len) { … }
bool
ultag_isUnicodeLocaleAttributes(const char* s, int32_t len) { … }
bool
ultag_isUnicodeLocaleKey(const char* s, int32_t len) { … }
bool
_isUnicodeLocaleTypeSubtag(const char*s, int32_t len) { … }
bool
ultag_isUnicodeLocaleType(const char*s, int32_t len) { … }
namespace {
bool
_isTKey(const char* s, int32_t len)
{ … }
}
const char*
ultag_getTKeyStart(const char *localeID) { … }
namespace {
bool
_isTValue(const char* s, int32_t len)
{ … }
bool
_isTransformedExtensionSubtag(int32_t& state, const char* s, int32_t len)
{ … }
bool
_isUnicodeExtensionSubtag(int32_t& state, const char* s, int32_t len)
{ … }
bool
_isStatefulSepListOf(bool (*test)(int32_t&, const char*, int32_t), const char* s, int32_t len)
{ … }
}
bool
ultag_isTransformedExtensionSubtags(const char* s, int32_t len)
{ … }
bool
ultag_isUnicodeExtensionSubtags(const char* s, int32_t len) { … }
namespace {
bool
_addVariantToList(VariantListEntry **first, icu::LocalPointer<VariantListEntry> var) { … }
bool
_addAttributeToList(AttributeListEntry **first, AttributeListEntry *attr) { … }
bool
_addExtensionToList(ExtensionListEntry **first, ExtensionListEntry *ext, bool localeToBCP) { … }
void
_initializeULanguageTag(ULanguageTag* langtag) { … }
void
_appendLanguageToLanguageTag(const char* localeID, icu::ByteSink& sink, bool strict, UErrorCode& status) { … }
void
_appendScriptToLanguageTag(const char* localeID, icu::ByteSink& sink, bool strict, UErrorCode& status) { … }
void
_appendRegionToLanguageTag(const char* localeID, icu::ByteSink& sink, bool strict, UErrorCode& status) { … }
void _sortVariants(VariantListEntry* first) { … }
void
_appendVariantsToLanguageTag(const char* localeID, icu::ByteSink& sink, bool strict, bool& hadPosix, UErrorCode& status) { … }
void
_appendKeywordsToLanguageTag(const char* localeID, icu::ByteSink& sink, bool strict, bool hadPosix, UErrorCode& status) { … }
void
_appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendTo, icu::MemoryPool<ExtensionListEntry>& extPool, icu::MemoryPool<icu::CharString>& kwdBuf, bool& posixVariant, UErrorCode& status) { … }
void
_appendKeywords(ULanguageTag* langtag, icu::ByteSink& sink, UErrorCode& status) { … }
void
_appendPrivateuseToLanguageTag(const char* localeID, icu::ByteSink& sink, bool strict, bool , UErrorCode& status) { … }
#define LANG …
#define EXTL …
#define SCRT …
#define REGN …
#define VART …
#define EXTS …
#define EXTV …
#define PRIV …
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && (_MSC_VER < 1924)
#pragma optimize( "", off )
#endif
ULanguageTag*
ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode& status) { … }
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && (_MSC_VER < 1924)
#pragma optimize( "", on )
#endif
void
ultag_close(ULanguageTag* langtag) { … }
const char*
ultag_getLanguage(const ULanguageTag* langtag) { … }
#if 0
const char*
ultag_getJDKLanguage(const ULanguageTag* langtag) {
int32_t i;
for (i = 0; DEPRECATEDLANGS[i] != nullptr; i += 2) {
if (uprv_compareInvCharsAsAscii(DEPRECATEDLANGS[i], langtag->language) == 0) {
return DEPRECATEDLANGS[i + 1];
}
}
return langtag->language;
}
#endif
const char*
ultag_getExtlang(const ULanguageTag* langtag, int32_t idx) { … }
int32_t
ultag_getExtlangSize(const ULanguageTag* langtag) { … }
const char*
ultag_getScript(const ULanguageTag* langtag) { … }
const char*
ultag_getRegion(const ULanguageTag* langtag) { … }
const char*
ultag_getVariant(const ULanguageTag* langtag, int32_t idx) { … }
int32_t
ultag_getVariantsSize(const ULanguageTag* langtag) { … }
const char*
ultag_getExtensionKey(const ULanguageTag* langtag, int32_t idx) { … }
const char*
ultag_getExtensionValue(const ULanguageTag* langtag, int32_t idx) { … }
int32_t
ultag_getExtensionsSize(const ULanguageTag* langtag) { … }
const char*
ultag_getPrivateUse(const ULanguageTag* langtag) { … }
#if 0
const char*
ultag_getLegacy(const ULanguageTag* langtag) {
return langtag->legacy;
}
#endif
}
U_CAPI int32_t U_EXPORT2
uloc_toLanguageTag(const char* localeID,
char* langtag,
int32_t langtagCapacity,
UBool strict,
UErrorCode* status) { … }
U_EXPORT icu::CharString
ulocimp_toLanguageTag(const char* localeID,
bool strict,
UErrorCode& status) { … }
U_EXPORT void
ulocimp_toLanguageTag(const char* localeID,
icu::ByteSink& sink,
bool strict,
UErrorCode& status) { … }
U_CAPI int32_t U_EXPORT2
uloc_forLanguageTag(const char* langtag,
char* localeID,
int32_t localeIDCapacity,
int32_t* parsedLength,
UErrorCode* status) { … }
U_EXPORT icu::CharString
ulocimp_forLanguageTag(const char* langtag,
int32_t tagLen,
int32_t* parsedLength,
UErrorCode& status) { … }
U_EXPORT void
ulocimp_forLanguageTag(const char* langtag,
int32_t tagLen,
icu::ByteSink& sink,
int32_t* parsedLength,
UErrorCode& status) { … }