7#if (defined(QT_STATIC) || defined(QT_BOOTSTRAPPED)) && defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1000
11#if defined(Q_OS_MACOS)
12# include "private/qcore_mac_p.h"
13# include <CoreFoundation/CoreFoundation.h>
16#include "qplatformdefs.h"
25#include <private/qtools_p.h>
26#if QT_CONFIG(datetimeparser)
27#include "private/qdatetimeparser_p.h"
35#if QT_CONFIG(timezone)
38#include "private/qnumeric_p.h"
39#include "private/qtools_p.h"
41#ifndef QT_NO_SYSTEMLOCALE
49#include "private/qcalendarbackend_p.h"
50#include "private/qgregoriancalendar_p.h"
60#ifndef QT_NO_SYSTEMLOCALE
62 QSystemLocale__CurrencyToStringArgument)
68#ifndef QT_NO_SYSTEMLOCALE
96 QLocale::LanguageCodeTypes codeTypes)
noexcept
107 if (uc1 > 0x7F || uc2 > 0x7F || uc3 > 0x7F)
110 const AlphaCode codeBuf = { char(uc1), char(uc2), char(uc3) };
112 auto searchCode = [codeBuf](
auto f) {
148 if (uc1 ==
'n' && uc2 ==
'o')
150 if (uc1 ==
't' && uc2 ==
'l')
152 if (uc1 ==
's' && uc2 ==
'h')
154 if (uc1 ==
'm' && uc2 ==
'o')
157 if (uc1 ==
'i' && uc2 ==
'w')
159 if (uc1 ==
'i' && uc2 ==
'n')
161 if (uc1 ==
'j' && uc2 ==
'i')
181 if (c0 ==
c[0] && c1 ==
c[1] &&
c2 ==
c[2] && c3 ==
c[3])
198 for (; *
c != 0;
c += 3) {
199 if (uc1 ==
c[0] && uc2 ==
c[1] && uc3 ==
c[2])
207 QLocale::LanguageCodeTypes codeTypes)
217 return i.part1.decode();
220 return i.part2B.decode();
223 return i.part2T.decode();
226 return i.part3.decode();
236 return {
reinterpret_cast<const char *
>(
c), 4};
245 return {
reinterpret_cast<const char*
>(
c),
c[2] == 0 ? 2 : 3};
255bool operator<(LikelyPair lhs, LikelyPair rhs)
259 const auto compare = [](
int lhs,
int rhs) {
261 const int huge = 0x10000;
262 return (lhs ? lhs : huge) - (rhs ? rhs : huge);
264 const auto &
left = lhs.key;
265 const auto &
right = rhs.key;
312 auto *pairs =
reinterpret_cast<const LikelyPair *
>(
likely_subtags);
314 LikelyPair sought { *
this };
319 pairs = std::lower_bound(pairs, afterPairs, sought);
322 for (; pairs < afterPairs && pairs->key.language_id ==
language_id; ++pairs) {
339 pairs = std::lower_bound(pairs, afterPairs, sought);
342 for (; pairs < afterPairs && pairs->key.territory_id ==
territory_id; ++pairs) {
358 pairs = std::lower_bound(pairs, afterPairs, sought);
359 if (pairs < afterPairs && pairs->
key.script_id ==
script_id) {
360 Q_ASSERT(!pairs->key.language_id && !pairs->key.territory_id);
371 pairs = std::lower_bound(pairs, afterPairs, sought);
372 if (pairs < afterPairs) {
425 const unsigned char *script =
427 const unsigned char *country =
430 qsizetype len = langLen + (script ? 4 + 1 : 0) + (country ? (country[2] != 0 ? 3 : 2) + 1 : 0);
432 char *uc =
name.data();
434 auto langArray = lang.
decode();
436 *uc++ = langArray[0];
437 *uc++ = langArray[1];
439 *uc++ = langArray[2];
473 if (localeId.language_id && idx == 0)
479 if (localeId.acceptScriptTerritory(
locale_data[idx].id()))
482 }
while (localeId.acceptLanguage(
locale_data[idx].m_language_id));
497 QVarLengthArray<QLocaleId, 6> tried;
498 tried.push_back(likelyId);
500#define CheckCandidate(id) do { \
501 if (!tried.contains(id)) { \
502 index = findLocaleIndexById(id); \
505 tried.push_back(id); \
513 if (lid.territory_id && (lid.language_id || lid.script_id)) {
514 localeId.territory_id = 0;
515 likelyId = localeId.withLikelySubtagsAdded();
523 if (lid.script_id && (lid.language_id || lid.territory_id)) {
525 likelyId = localeId.withLikelySubtagsAdded();
539 const std::u16string_view
v(
name.utf16(),
size_t(
name.size()));
540 const auto i =
v.find_first_of(u
"_-.@");
541 if (
i == std::string_view::npos)
550 const char16_t ch = uc.unicode();
554 return tag.size() > 0;
561 static const QString allScripts =
564 return tag.size() == 4 && allScripts.indexOf(
tag) % 4 == 0;
570 enum ParserState { NoState, LangState, ScriptState, CountryState };
571 ParserState
state = LangState;
572 while (
name.size() &&
state != NoState) {
577 const bool sep =
name.size() > 0;
583 if (
tag.size() != 2 &&
tag.size() != 3)
587 state =
sep ? ScriptState : NoState;
593 state =
sep ? CountryState : NoState;
608 return state != LangState;
633 if (
format.at(
i).unicode() ==
'\'') {
641 if (
format.at(
i).unicode() ==
'\'') {
642 if (
format.mid(
i + 1).startsWith(u
'\'')) {
681 while (
j <
s.size() &&
s.at(
j) ==
c)
695#ifndef QT_NO_SYSTEMLOCALE
755 return &globalInstance;
795#ifndef QT_NO_SYSTEMLOCALE
806 bool updated =
false;
809 systemDataMutex.
lock();
815 if (sysIndex && (updated || *sysIndex < 0)) {
817 if (sysId != nowId || *sysIndex < 0) {
823 systemDataMutex.unlock();
843#ifndef QT_NO_SYSTEMLOCALE
862#ifndef QT_NO_DATASTREAM
908 if (defaultLocalePrivate.exists())
909 numberOptions = defaultLocalePrivate->data()->m_numberOptions;
916static std::optional<QString>
919#ifndef QT_NO_SYSTEMLOCALE
924 if (
v.metaType() != QMetaType::fromType<QString>())
970#ifndef QT_NO_SYSTEMLOCALE
975 return text.
at(0).unicode();
1052 :
d(localePrivateByName(
name))
1071 :
d(*defaultLocalePrivate)
1214#ifndef QT_NO_SYSTEMLOCALE
1224 return res.toString();
1249#ifndef QT_NO_SYSTEMLOCALE
1255 return res.toString();
1267 return d->
m_data->pairListPattern().getData(
1299 if (defaultLocalePrivate.isDestroyed())
1301 if (!defaultLocalePrivate.exists()) {
1304 Q_ASSERT(defaultLocalePrivate.exists());
1308 *defaultLocalePrivate = locale.d;
1346#if QT_DEPRECATED_SINCE(6, 6)
1388 qWarning(
"QLocale::%s(): Using non-ASCII separator '%c' (%02x) is unsupported",
1414 const char sep = char(separator);
1433template <
typename T>
static inline
1436 constexpr bool isUnsigned = std::is_unsigned_v<T>;
1437 using Int64 =
typename std::conditional_t<isUnsigned, quint64, qint64>;
1439 QSimpleParsedNumber<Int64>
r{};
1440 if constexpr (isUnsigned)
1441 r =
d->m_data->stringToUnsLongLong(
str, 10,
d->m_numberOptions);
1443 r =
d->m_data->stringToLongLong(
str, 10,
d->m_numberOptions);
1484 const char sep = char(separator);
1531 LanguageCodeTypes codeTypes)
noexcept
1566#if QT_DEPRECATED_SINCE(6, 6)
1577QString QLocale::countryToCode(Country country)
1635 return "Unknown"_L1;
1649 return "Unknown"_L1;
1653#if QT_DEPRECATED_SINCE(6, 6)
1661QString QLocale::countryToString(Country country)
1677 return "Unknown"_L1;
1855 return toIntegral_helper<short>(d,
s,
ok);
1875 return toIntegral_helper<ushort>(d,
s,
ok);
1895 return toIntegral_helper<int>(d,
s,
ok);
1915 return toIntegral_helper<uint>(d,
s,
ok);
1934 return toIntegral_helper<long>(d,
s,
ok);
1954 return toIntegral_helper<ulong>(d,
s,
ok);
1975 return toIntegral_helper<qlonglong>(d,
s,
ok);
1996 return toIntegral_helper<qulonglong>(d,
s,
ok);
2149#ifndef QT_NO_SYSTEMLOCALE
2156 return res.toString();
2173#ifndef QT_NO_SYSTEMLOCALE
2180 return res.toString();
2192 if (
format.at(
i).unicode() ==
'\'') {
2197 if (
format.at(
i).toLower().unicode() ==
'a')
2257#ifndef QT_NO_SYSTEMLOCALE
2264 return res.toString();
2281#ifndef QT_NO_SYSTEMLOCALE
2288 return res.toString();
2307#ifndef QT_NO_SYSTEMLOCALE
2314 return res.toString();
2336#ifndef QT_NO_SYSTEMLOCALE
2343 return res.toString();
2348 ? d->
m_data->longDateFormat()
2349 : d->
m_data->shortDateFormat()
2367#ifndef QT_NO_SYSTEMLOCALE
2374 return res.toString();
2379 ? d->
m_data->longTimeFormat()
2380 : d->
m_data->shortTimeFormat()
2398#ifndef QT_NO_SYSTEMLOCALE
2404 if (!
res.isNull()) {
2405 return res.toString();
2412#if QT_CONFIG(datestring)
2524#if QT_CONFIG(datetimeparser)
2526 dt.setDefaultLocale(*
this);
2527 if (dt.parseFormat(
format))
2528 dt.fromString(
string,
nullptr, &
time);
2573#if QT_CONFIG(datetimeparser)
2575 dt.setDefaultLocale(*
this);
2576 if (dt.parseFormat(
format))
2577 dt.fromString(
string, &
date,
nullptr, baseYear);
2622#if QT_CONFIG(datetimeparser)
2626 dt.setDefaultLocale(*
this);
2627 if (dt.parseFormat(
format) && (dt.fromString(
string, &datetime, baseYear)
2864 constexpr auto sysData = []() {
2866#ifdef QT_NO_SYSTEMLOCALE
2897 return QList<QLocale>();
2910 if (
filter.acceptScriptTerritory(
id)) {
2920 if (
filter.acceptLanguage(syslocaledata->m_language_id)) {
2921 const QLocaleId id = syslocaledata->id();
2922 if (
filter.acceptScriptTerritory(
id))
2929#if QT_DEPRECATED_SINCE(6, 6)
2944 result.reserve(locales.size());
2945 for (
const auto &locale : locales)
3024 return locale->m_language_id ==
calendar.m_language_id
3025 && locale->m_script_id ==
calendar.m_script_id
3026 && locale->m_territory_id ==
calendar.m_territory_id;
3034 const char16_t *monthsData,
int month,
3040 range = localeData.longMonth();
3043 range = localeData.shortMonth();
3046 range = localeData.narrowMonth();
3051 return range.getListEntry(monthsData, month - 1);
3059 const char16_t *monthsData,
int month,
3065 range = localeData.longMonthStandalone();
3068 range = localeData.shortMonthStandalone();
3071 range = localeData.narrowMonthStandalone();
3117 range =
data->shortDayNamesStandalone();
3120 range =
data->narrowDayNamesStandalone();
3145#ifndef QT_NO_SYSTEMLOCALE
3147 Q_ASSERT(month >= 1 && month <= 12);
3162 return res.toString();
3181#ifndef QT_NO_SYSTEMLOCALE
3183 Q_ASSERT(month >= 1 && month <= 12);
3198 return res.toString();
3210 if (day < 1 || day > 7)
3213#ifndef QT_NO_SYSTEMLOCALE
3229 return res.toString();
3239 if (day < 1 || day > 7)
3242#ifndef QT_NO_SYSTEMLOCALE
3258 return res.toString();
3274#ifndef QT_NO_SYSTEMLOCALE
3287 if (system.languageId ==
m_data->m_language_id
3288 && system.territoryId ==
m_data->m_territory_id) {
3289 return system.system;
3302#ifndef QT_NO_SYSTEMLOCALE
3314 if ((weekendEnd >= weekendStart && (day < weekendStart || day > weekendEnd)) ||
3315 (weekendEnd < weekendStart && (day > weekendEnd && day < weekendStart)))
3328#ifndef QT_NO_SYSTEMLOCALE
3441#ifndef QT_NO_SYSTEMLOCALE
3461#ifndef QT_NO_SYSTEMLOCALE
3479 bool formatDate =
false;
3480 bool formatTime =
false;
3486 }
else if (dateOnly.isValid()) {
3489 }
else if (timeOnly.isValid()) {
3497 int year = 0, month = 0, day = 0;
3500 if (!parts.isValid())
3503 month = parts.month;
3507 auto appendToResult = [&](
int t,
int repeat) {
3508 auto data = locale.d->m_data;
3515 auto formatType = [](
int repeat) {
3521 if (
format.at(
i).unicode() ==
'\'') {
3528 Q_ASSERT(rep < std::numeric_limits<int>::max());
3529 int repeat = int(rep);
3532 switch (
c.unicode()) {
3537 else if (repeat >= 2)
3542 appendToResult(year, (year < 0) ? 5 : 4);
3545 appendToResult(year % 100, 2);
3556 repeat =
qMin(repeat, 4);
3558 appendToResult(month, repeat);
3565 repeat =
qMin(repeat, 4);
3567 appendToResult(day, repeat);
3577 if (!used && formatTime) {
3578 switch (
c.unicode()) {
3581 repeat =
qMin(repeat, 2);
3589 appendToResult(hour, repeat);
3594 repeat =
qMin(repeat, 2);
3595 appendToResult(
time.
hour(), repeat);
3600 repeat =
qMin(repeat, 2);
3606 repeat =
qMin(repeat, 2);
3617 if (
c.unicode() ==
'A' && (repeat == 1 ||
format.at(
i + 1).unicode() ==
'P'))
3619 else if (
c.unicode() ==
'a' && (repeat == 1 ||
format.at(
i + 1).unicode() ==
'p'))
3628 repeat =
qMin(repeat, 3);
3634 if (
result.endsWith(locale.zeroDigit()))
3636 if (
result.endsWith(locale.zeroDigit()))
3642 enum AbbrType { Long,
Offset, Short };
3643 const auto tzAbbr = [locale](
const QDateTime &when, AbbrType
type) {
3644#if QT_CONFIG(timezone)
3646 QTimeZone::NameType
mode =
3647 type == Short ? QTimeZone::ShortName
3648 :
type == Long ? QTimeZone::LongName : QTimeZone::OffsetName;
3658 repeat =
qMin(repeat, 4);
3664 text = tzAbbr(when, Long);
3681 text = tzAbbr(when, Short);
3722 bufSize += std::numeric_limits<double>::max_digits10;
3730 bool negative =
false;
3747 }
else if (
zero.size() == 2 &&
zero.at(0).isHighSurrogate()) {
3748 const char32_t zeroUcs4 = QChar::surrogateToUcs4(
zero.at(0),
zero.at(1));
3753 Q_ASSERT(QChar::requiresSurrogates(digit));
3754 converted.
append(QChar::highSurrogate(digit));
3755 converted.
append(QChar::lowSurrogate(digit));
3761 char16_t z =
zero.at(0).unicode();
3762 char16_t *
const value =
reinterpret_cast<char16_t *
>(
digits.data());
3772 numStr = exponentForm(std::move(
digits), decpt,
precision, PMDecimalDigits,
3773 mustMarkDecimal, minExponentDigits);
3776 numStr = decimalForm(std::move(
digits), decpt,
precision, PMDecimalDigits,
3777 mustMarkDecimal, groupDigits);
3799 int bias = 2 + minExponentDigits;
3804 if (decpt > 10 && minExponentDigits == 1)
3810 if (!mustMarkDecimal) {
3813 if (digitCount <= decpt && digitCount > 1)
3823 useDecimal = (decpt <= 0 ? 1 - decpt <=
bias
3833 mustMarkDecimal, groupDigits)
3835 mustMarkDecimal, minExponentDigits);
3843 numStr.prepend(
zero);
3847 return prefix + (
flags &
CapitalEorX ? std::move(numStr).toUpper() : numStr);
3851 PrecisionMode pm,
bool mustMarkDecimal,
3852 bool groupDigits)
const
3855 const auto digitWidth =
zero.size();
3856 Q_ASSERT(digitWidth == 1 || digitWidth == 2);
3862 for (; decpt < 0; ++decpt)
3870 case PMDecimalDigits:
3874 case PMSignificantDigits:
3878 case PMChopTrailingZeros:
3883 if (mustMarkDecimal || decpt <
digits.size() / digitWidth)
3899 return std::move(
digits);
3903 PrecisionMode pm,
bool mustMarkDecimal,
3904 int minExponentDigits)
const
3907 const auto digitWidth =
zero.size();
3908 Q_ASSERT(digitWidth == 1 || digitWidth == 2);
3912 case PMDecimalDigits:
3916 case PMSignificantDigits:
3920 case PMChopTrailingZeros:
3925 if (mustMarkDecimal ||
digits.size() > digitWidth)
3931 return std::move(
digits);
3934QString QLocaleData::signPrefix(
bool negative,
unsigned flags)
const
3948 bool negative =
n < 0;
3965 return applyIntegerFormatting(l ?
qulltoa(l,
base,
zero) : resultZero,
3973 const auto digitWidth =
zero.size();
3974 const auto digitCount = numStr.size() / digitWidth;
3980 return upper ? u
"0X" : u
"0x";
3982 return upper ? u
"0B" : u
"0b";
3983 if (
base == 8 && !numStr.startsWith(
zero))
3989 const QString prefix = signPrefix(negative,
flags) + basePrefix;
3997 numStr.insert(
i * digitWidth,
group);
4000 numStr.insert(
i * digitWidth,
group);
4007 const bool noPrecision =
precision == -1;
4012 numStr.prepend(
zero);
4020 numStr.prepend(
zero);
4048#ifndef QT_NO_SYSTEMLOCALE
4051 return sys->query(
query).toString();
4055 if (
result.sysDecimal.size())
4059 if (
result.sysGroup.size())
4062 if (
result.sysMinus.size())
4065 if (
result.sysPlus.size())
4078class NumericTokenizer
4082 static constexpr char lettersInfNaN[] =
"afin";
4083 static constexpr auto matchInfNaN = QtPrivate::makeCharacterSetMatch<lettersInfNaN>();
4088 static_assert(
'+' + 1 ==
',' &&
',' + 1 ==
'-' &&
'-' + 1 ==
'.');
4093 : m_text(
text), m_guide(guide), m_mode(
mode),
4098 bool done()
const {
return !(m_index < m_text.
size()); }
4100 inline int asBmpDigit(
char16_t digit)
const;
4104int NumericTokenizer::asBmpDigit(
char16_t digit)
const
4109 return digit - m_guide.
zeroUcs;
4112 if (digit == u
'\u3020')
4115 return digit - u
'\u3020';
4118char NumericTokenizer::nextToken()
4124 const auto asciiLower = [](
unsigned char c) {
return c >=
'A' ?
c | 0x20 :
c; };
4127 if (
ch == u
'\u2212') {
4141 && matchInfNaN.matches(ascii))
4143 && ascii ==
'e'))) {
4149 if (
ch.unicode() < 256) {
4152 if (
isAsciiDigit(ascii) || ascii ==
'-' || ascii ==
'+'
4185 if (!
ch.isSurrogate()) {
4186 const uint gap = asBmpDigit(
ch.unicode());
4191 }
else if (
ch.isHighSurrogate() && tail.
size() > 1 && tail.
at(1).isLowSurrogate()) {
4194 }
else if (
ch.isHighSurrogate()) {
4197 if (tail.
size() > 1) {
4199 if (low.isLowSurrogate()) {
4201 const uint gap = QChar::surrogateToUcs4(
ch, low) - m_guide.
zeroUcs;
4202 return gap < 10u ?
'0' + gap : 0;
4210 Q_ASSERT(!(
ch.isHighSurrogate() && tail.
size() > 1 && tail.
at(1).isLowSurrogate()));
4262 NumericTokenizer tokens(
s, numericData(
mode),
mode);
4274 while (!tokens.done()) {
4276 char out = tokens.nextToken();
4283 if (decpt_idx != -1 || exponent_idx != -1)
4286 }
else if (
out ==
'e') {
4291 && exponent_idx != -1 &&
out ==
'0') {
4301 if (idx == exponent_idx && last ==
'0')
4307 if (start_of_digits_idx == -1)
4308 start_of_digits_idx = idx;
4310 }
else if (
out ==
',') {
4312 if (decpt_idx != -1 || exponent_idx != -1)
4315 if (last_separator_idx == -1) {
4317 if (start_of_digits_idx == -1 || m_grouping_top > digitsInGroup
4318 || digitsInGroup >= m_grouping_least + m_grouping_top) {
4323 if (digitsInGroup != m_grouping_higher)
4327 last_separator_idx = idx;
4329 }
else if (
mode != IntegerMode && (
out ==
'.' || idx == exponent_idx)
4330 && last_separator_idx != -1) {
4332 if (digitsInGroup != m_grouping_least)
4336 last_separator_idx = -1;
4338 }
else if (
out ==
',') {
4349 if (digitsInGroup != m_grouping_least)
4354 && decpt_idx != -1 && exponent_idx == -1) {
4366 QLocale::NumberOptions number_options)
const
4371 enum { Whole, Fractional, Exponent }
state = Whole;
4372 const bool scientific = numMode == DoubleScientificMode;
4373 NumericTokenizer tokens(
str, numericData(numMode), numMode);
4376 while (!tokens.done()) {
4377 char c = tokens.nextToken();
4386 if (decDigits-- == 0)
4404 if (numMode == IntegerMode ||
state != Whole)
4415 if (last !=
'\0' && !(scientific && last ==
'e'))
4431 if (!scientific ||
state == Exponent)
4441 Q_ASSERT(!
c ||
c ==
'a' ||
c ==
'f' ||
c ==
'i' ||
c ==
'n');
4455 if (last ==
',' || last ==
'-' || last ==
'+' || last ==
'e')
4462 QLocale::NumberOptions number_options)
const
4465 if (!numberToCLocale(
str, number_options, DoubleScientificMode, &buff)) {
4476QSimpleParsedNumber<qint64>
4478 QLocale::NumberOptions number_options)
const
4481 if (!numberToCLocale(
str, number_options, IntegerMode, &buff))
4487QSimpleParsedNumber<quint64>
4489 QLocale::NumberOptions number_options)
const
4492 if (!numberToCLocale(
str, number_options, IntegerMode, &buff))
4504 if (used <
len &&
num[used] !=
'\0') {
4509 if (used <
len &&
num[used] !=
'\0')
4550#ifndef QT_NO_SYSTEMLOCALE
4558 case CurrencySymbol:
4560 case CurrencyDisplayName:
4562 case CurrencyIsoCode: {
4563 const char *code =
d->m_data->m_currency_iso_code;
4582#ifndef QT_NO_SYSTEMLOCALE
4593 range =
d->m_data->currencyFormat();
4599 sym = currencySymbol(CurrencyIsoCode);
4609#ifndef QT_NO_SYSTEMLOCALE
4621 sym = currencySymbol(CurrencyIsoCode);
4637#ifndef QT_NO_SYSTEMLOCALE
4648 range =
d->m_data->currencyFormat();
4654 sym = currencySymbol(CurrencyIsoCode);
4697 int power,
base = 1000;
4700 }
else if (
format & DataSizeBase1000) {
4701 power = int(std::log10(
qAbs(bytes)) / 3);
4713 Q_ASSERT(power <= 6 && power >= 0);
4717 ?
d->m_data->byteAmountSI() :
d->m_data->byteAmountIEC();
4723 return number + u
' ' + unit;
4750 const char sep = char(separator);
4756 QList<QLocaleId> localeIds;
4757#ifdef QT_NO_SYSTEMLOCALE
4758 constexpr bool isSystem =
false;
4763 if (separator != TagSeparator::Dash) {
4766 uiLanguages = uiLanguages.replaceInStrings(u
"-",
QStringView(&join, 1));
4770 for (
const auto &
entry : std::as_const(uiLanguages))
4772 if (localeIds.isEmpty())
4773 localeIds.append(
systemLocale()->fallbackLocale().d->m_data->id());
4787 if (std::none_of(uiLanguages.constBegin(), uiLanguages.constEnd(), isMine)) {
4788 localeIds.prepend(
d->m_data->id());
4789 uiLanguages.prepend(
name);
4795 localeIds.append(
d->m_data->id());
4801 if (isSystem &&
i < uiLanguages.size()) {
4804 prior = uiLanguages.at(
i).toLatin1();
4807 }
else if (
id.language_id == C) {
4813 prior =
id.name(
sep);
4815 j = uiLanguages.size();
4830 if (
id != min &&
id.withLikelySubtagsAdded() == max) {
4836 if (!
id.territory_id) {
4841 if (
id != max &&
id.withLikelySubtagsAdded() == max) {
4848 if (max != min && max !=
id) {
4869#ifndef QT_NO_SYSTEMLOCALE
4889#ifndef QT_NO_SYSTEMLOCALE
4909#ifndef QT_NO_SYSTEMLOCALE
4919#if QT_DEPRECATED_SINCE(6, 6)
4929QString QLocale::nativeCountryName()
const
4931 return nativeTerritoryName();
4935#ifndef QT_NO_DEBUG_STREAM
4939 dbg.nospace().noquote()
4948#ifndef QT_NO_QOBJECT
4949#include "moc_qlocale.cpp"
virtual QString standaloneWeekDayName(const QLocale &locale, int day, QLocale::FormatType format) const
Returns the standalone name of the specified day of the week in the chosen locale,...
virtual const char16_t * localeMonthData() const =0
virtual QString standaloneMonthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const
Returns the standalone name of the specified month in the chosen locale, using the specified format t...
virtual QString dateTimeToString(QStringView format, const QDateTime &datetime, QDate dateOnly, QTime timeOnly, const QLocale &locale) const
Returns a string representing a given date, time or date-time.
virtual const QCalendarLocale * localeMonthIndexData() const =0
virtual int dayOfWeek(qint64 jd) const
Returns the day of the week for the given Julian Day Number jd.
virtual QString weekDayName(const QLocale &locale, int day, QLocale::FormatType format) const
Returns the name of the specified day of the week in the chosen locale, using the specified format to...
virtual QCalendar::YearMonthDay julianDayToDate(qint64 jd) const =0
Computes the year, month, and day in this calendar for the given Julian day number jd.
virtual QString monthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const
Returns the name of the specified month in the given year for the chosen locale, using the given form...
virtual int maximumMonthsInYear() const
Returns the maximum number of months possible in any year.
The QCalendar class describes calendar systems.
QString standaloneMonthName(const QLocale &locale, int month, int year=Unspecified, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised standalone name for a month.
QString dateTimeToString(QStringView format, const QDateTime &datetime, QDate dateOnly, QTime timeOnly, const QLocale &locale) const
Returns a string representing a given date, time or date-time.
QString monthName(const QLocale &locale, int month, int year=Unspecified, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised name for a month.
QString standaloneWeekDayName(const QLocale &locale, int day, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised standalone name for a day of the week.
QString weekDayName(const QLocale &locale, int day, QLocale::FormatType format=QLocale::LongFormat) const
Returns a suitably localised name for a day of the week.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
int offsetFromUtc() const
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTime time() const
Returns the time part of the datetime.
QString timeZoneAbbreviation() const
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
QDateTime toOffsetFromUtc(int offsetSeconds) const
QTimeZone timeRepresentation() const
QDate date() const
Returns the date part of the datetime.
\inmodule QtCore \reentrant
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
constexpr qint64 toJulianDay() const
Converts the date to a Julian day.
QVariant data(int key) const
Returns this item's custom data for the key key as a QVariant.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
static QLatin1StringView scriptToCode(QLocale::Script script)
quint16 languageId() const
static QLocale::Language codeToLanguage(QStringView code, QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode) noexcept
const QLocaleData *const m_data
QLocale::MeasurementSystem measurementSystem() const
quint16 territoryId() const
static QLatin1StringView territoryToCode(QLocale::Territory territory)
static QLocale::Territory codeToTerritory(QStringView code) noexcept
static std::array< char, 4 > languageToCode(QLocale::Language language, QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode)
static QLocale::Script codeToScript(QStringView code) noexcept
QLocale::NumberOptions m_numberOptions
QLatin1StringView territoryCode() const
std::array< char, 4 > languageCode(QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode) const
static QBasicAtomicInt s_generation
QByteArray bcp47Name(char separator='-') const
QString decimalPoint() const
static QString languageToCode(Language language, LanguageCodeTypes codeTypes=AnyLanguageCode)
Returns the two- or three-letter language code for language, as defined in the ISO 639 standards.
QString quoteString(const QString &str, QuotationStyle style=StandardQuotation) const
QString dateTimeFormat(FormatType format=LongFormat) const
Language language() const
Returns the language of this locale.
QString zeroDigit() const
QLocale & operator=(const QLocale &other) noexcept
Assigns other to this QLocale object and returns a reference to this QLocale object.
double toDouble(const QString &s, bool *ok=nullptr) const
Returns the double represented by the localized string s.
QString dateFormat(FormatType format=LongFormat) const
static constexpr int DefaultTwoDigitBaseYear
float toFloat(const QString &s, bool *ok=nullptr) const
Returns the float represented by the localized string s.
static QString scriptToString(Script script)
void setNumberOptions(NumberOptions options)
QString negativeSign() const
Qt::DayOfWeek firstDayOfWeek() const
uint toUInt(const QString &s, bool *ok=nullptr) const
Returns the unsigned int represented by the localized string s.
QString toUpper(const QString &str) const
long toLong(const QString &s, bool *ok=nullptr) const
Qt::LayoutDirection textDirection() const
static Territory codeToTerritory(QStringView territoryCode) noexcept
QString dayName(int, FormatType format=LongFormat) const
@ InscriptionalParthianScript
@ InscriptionalPahlaviScript
static QString territoryToCode(Territory territory)
QString toCurrencyString(qlonglong, const QString &symbol=QString()) const
QString timeFormat(FormatType format=LongFormat) const
QString groupSeparator() const
QString createSeparatedList(const QStringList &strl) const
static void setDefault(const QLocale &locale)
\nonreentrant
QString monthName(int, FormatType format=LongFormat) const
static QString territoryToString(Territory territory)
MeasurementSystem measurementSystem() const
QLocale collation() const
QString bcp47Name(TagSeparator separator=TagSeparator::Dash) const
Returns the BCP47 field names joined with dashes.
QString nativeTerritoryName() const
static Script codeToScript(QStringView scriptCode) noexcept
Returns the QLocale::Script enum corresponding to the four-letter script scriptCode,...
static QString languageToString(Language language)
Returns a QString containing the name of language.
int toInt(const QString &s, bool *ok=nullptr) const
Returns the int represented by the localized string s.
static QString scriptToCode(Script script)
Returns the four-letter script code for script, as defined in the ISO 15924 standard.
QString exponential() const
QString formattedDataSize(qint64 bytes, int precision=2, DataSizeFormats format=DataSizeIecFormat) const
qulonglong toULongLong(const QString &s, bool *ok=nullptr) const
Returns the unsigned long long int represented by the localized string s.
QList< Qt::DayOfWeek > weekdays() const
QString positiveSign() const
QStringList uiLanguages(TagSeparator separator=TagSeparator::Dash) const
List of locale names for use in selecting translations.
QString toString(qlonglong i) const
Returns a localized string representation of i.
ulong toULong(const QString &s, bool *ok=nullptr) const
QString standaloneMonthName(int, FormatType format=LongFormat) const
NumberOptions numberOptions() const
short toShort(const QString &s, bool *ok=nullptr) const
Returns the short int represented by the localized string s.
Territory territory() const
qlonglong toLongLong(const QString &s, bool *ok=nullptr) const
Returns the long long int represented by the localized string s.
QLocale()
Constructs a QLocale object initialized with the default locale.
QString name(TagSeparator separator=TagSeparator::Underscore) const
The short name of this locale.
ushort toUShort(const QString &s, bool *ok=nullptr) const
Returns the unsigned short int represented by the localized string s.
QString nativeLanguageName() const
static Language codeToLanguage(QStringView languageCode, LanguageCodeTypes codeTypes=AnyLanguageCode) noexcept
Returns the QLocale::Language enum corresponding to the two- or three-letter languageCode,...
QString toLower(const QString &str) const
QString standaloneDayName(int, FormatType format=LongFormat) const
QString currencySymbol(CurrencySymbolFormat=CurrencySymbol) const
friend class QLocalePrivate
@ RejectTrailingZeroesAfterDot
@ RejectLeadingZeroInExponent
@ IncludeTrailingZeroesAfterDot
@ OmitLeadingZeroInExponent
static QList< QLocale > matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Territory territory)
Returns a list of valid locale objects that match the given language, script and territory.
static QLocale system()
Returns a QLocale object initialized to the system locale.
void lock() noexcept
Locks the mutex.
QString standaloneMonthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const override
Returns the standalone name of the specified month in the chosen locale, using the specified format t...
QString monthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const override
Returns the name of the specified month in the given year for the chosen locale, using the given form...
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
QString arg(Args &&...args) const
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QChar at(qsizetype n) const noexcept
Returns the character at position n in this string view.
constexpr QChar front() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
QString sliced(qsizetype pos) const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
bool isNull() const
Returns true if this string is null; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QString toLower() const &
QChar * data()
Returns a pointer to the data stored in the QString.
QString & append(QChar c)
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QString toUpper() const &
const QChar * unicode() const
Returns a Unicode representation of the string.
void resize(qsizetype size)
Sets the size of the string to size characters.
@ StringToAlternateQuotation
@ StandaloneMonthNameLong
@ StandaloneDayNameNarrow
@ StandaloneMonthNameNarrow
@ StringToStandardQuotation
@ StandaloneMonthNameShort
\inmodule QtCore \reentrant
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
bool isValid() const
Returns true if the time is valid; otherwise returns false.
int msec() const
Returns the millisecond part (0 to 999) of the time.
int second() const
Returns the second part (0 to 59) of the time.
constexpr size_type size() const noexcept
const T * constData() const
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
list append(new Employee("Blackpool", "Stephen"))
Combined button and popup list for selecting options.
constexpr bool isAsciiDigit(char32_t c) noexcept
constexpr bool isAsciiLetterOrNumber(char32_t c) noexcept
constexpr bool isAsciiUpper(char32_t c) noexcept
constexpr char toAsciiLower(char ch) noexcept
static constexpr bool q_points_into_range(const T *p, const T *b, const T *e, Cmp less={}) noexcept
constexpr Initialization Uninitialized
constexpr auto ssize(const C &c) -> std::common_type_t< std::ptrdiff_t, std::make_signed_t< decltype(c.size())> >
QT_POPCOUNT_RELAXED_CONSTEXPR uint qCountLeadingZeroBits(quint32 v) noexcept
#define Q_BASIC_ATOMIC_INITIALIZER(a)
static constexpr uchar asciiLower(uchar c)
#define QByteArrayLiteral(str)
int qstrncmp(const char *str1, const char *str2, size_t len)
size_t qstrnlen(const char *str, size_t maxlen)
#define Q_DECL_COLD_FUNCTION
#define QT_WARNING_DISABLE_GCC(text)
AudioChannelLayoutTag tag
static qsizetype digitCount(QStringView str)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
static Q_CONSTINIT QSystemLocale * _systemLocale
QDataStream & operator<<(QDataStream &ds, const QLocale &l)
static constexpr qsizetype locale_data_size
static QLocalePrivate * findLocalePrivate(QLocale::Language language, QLocale::Script script, QLocale::Territory territory)
static qsizetype findLocaleIndexById(QLocaleId localeId)
static std::optional< QString > systemLocaleString(const QLocaleData *that, QSystemLocale::QueryType type)
static const QSystemLocale * systemLocale()
static bool checkParsed(QByteArrayView num, qsizetype used)
static QString rawWeekDayName(const QLocaleData *data, const int day, QLocale::FormatType type)
QDataStream & operator>>(QDataStream &ds, QLocale &l)
static Q_CONSTINIT const QLocaleData * default_data
static Q_CONSTINIT QLocaleData systemLocaleData
#define CheckCandidate(id)
static Q_DECL_COLD_FUNCTION void badSeparatorWarning(const char *method, char sep)
static QString rawStandaloneWeekDayName(const QLocaleData *data, const int day, QLocale::FormatType type)
static QStringView findTag(QStringView name) noexcept
static bool validTag(QStringView tag)
static QLocalePrivate * c_private()
static bool isScript(QStringView tag)
static T toIntegral_helper(const QLocalePrivate *d, QStringView str, bool *ok)
static bool timeFormatContainsAP(QStringView format)
static bool sameLocale(const QLocaleData *locale, const QCalendarLocale &calendar)
qsizetype qt_repeatCount(QStringView s)
bool qt_splitLocaleName(QStringView name, QStringView *lang, QStringView *script, QStringView *land)
static void updateSystemPrivate()
static QString rawMonthName(const QCalendarLocale &localeData, const char16_t *monthsData, int month, QLocale::FormatType type)
QString qt_readEscapedFormatString(QStringView format, qsizetype *idx)
static const QLocaleData * defaultData()
static QString rawStandaloneMonthName(const QCalendarLocale &localeData, const char16_t *monthsData, int month, QLocale::FormatType type)
static QString localeString(const QLocaleData *that, QSystemLocale::QueryType type, QLocaleData::DataRange range)
static const QLocaleData * systemData(qsizetype *sysIndex=nullptr)
static qsizetype defaultIndex()
static constexpr char16_t single_character_data[]
static constexpr char16_t days_data[]
constexpr std::array< LanguageCodeEntry, 344 > languageCodeList
static constexpr quint16 locale_index[]
static constexpr char16_t pm_data[]
static constexpr TerritoryLanguage ImperialMeasurementSystems[]
static constexpr QLocaleData locale_data[]
static constexpr char16_t endonyms_data[]
static constexpr QLocaleId likely_subtags[]
static constexpr char territory_name_list[]
static constexpr char16_t am_data[]
static constexpr char16_t currency_format_data[]
static constexpr unsigned char territory_code_list[]
static constexpr quint16 territory_name_index[]
static constexpr char language_name_list[]
static constexpr quint16 script_name_index[]
static constexpr char16_t byte_unit_data[]
static constexpr quint16 language_name_index[]
static constexpr char16_t list_pattern_part_data[]
static constexpr char16_t date_format_data[]
static constexpr char16_t currency_display_name_data[]
static constexpr char16_t time_format_data[]
static constexpr char script_name_list[]
static constexpr char16_t currency_symbol_data[]
static constexpr unsigned char script_code_list[]
bool qt_splitLocaleName(QStringView name, QStringView *lang=nullptr, QStringView *script=nullptr, QStringView *cntry=nullptr)
constexpr bool ascii_isspace(uchar c)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
static Q_DECL_CONST_FUNCTION bool qt_is_finite(double d)
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLsizei GLsizei GLenum format
GLenum GLint GLint * precision
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static constexpr QChar sep
static ISC_DATE toDate(QDate t)
static ISC_TIME toTime(QTime t)
#define QStringLiteral(str)
QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept
#define QT_BEGIN_INCLUDE_NAMESPACE
#define QT_END_INCLUDE_NAMESPACE
static int compare(quint64 a, quint64 b)
unsigned long long quint64
static QByteArray getData(int cf, IDataObject *pDataObj, int lindex=-1)
static QString getString(IMFActivate *device, const IID &id)
QTextStream out(stdout)
[7]
char * toString(const MyType &t)
[31]
std::array< char, 4 > decode() const
\inmodule QtCore \reentrant
bool isValid(NumberMode mode) const
QString positiveSign() const
static float convertDoubleToFloat(double d, bool *ok)
QString groupSeparator() const
QSimpleParsedNumber< qint64 > stringToLongLong(QStringView str, int base, QLocale::NumberOptions options) const
QString zeroDigit() const
Q_CORE_EXPORT ParsingResult validateChars(QStringView str, NumberMode numMode, int decDigits=-1, QLocale::NumberOptions number_options=QLocale::DefaultNumberOptions) const
bool numberToCLocale(QStringView s, QLocale::NumberOptions number_options, NumberMode mode, CharBuff *result) const
QString decimalPoint() const
QString doubleToString(double d, int precision=-1, DoubleForm form=DFSignificantDigits, int width=-1, unsigned flags=NoFlags) const
static const QLocaleData * c()
QString listSeparator() const
static qsizetype findLocaleIndex(QLocaleId localeId)
static QSimpleParsedNumber< quint64 > bytearrayToUnsLongLong(QByteArrayView num, int base)
QString percentSign() const
double stringToDouble(QStringView str, bool *ok, QLocale::NumberOptions options) const
QString longLongToString(qint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
quint8 m_first_day_of_week
NumericData numericData(NumberMode mode) const
QString exponentSeparator() const
QString negativeSign() const
static Q_CORE_EXPORT QSimpleParsedNumber< qint64 > bytearrayToLongLong(QByteArrayView num, int base)
QSimpleParsedNumber< quint64 > stringToUnsLongLong(QStringView str, int base, QLocale::NumberOptions options) const
QString unsLongLongToString(quint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
QLocaleId withLikelySubtagsRemoved() const
QLocaleId withLikelySubtagsAdded() const
Fill in blank fields of a locale ID.
QByteArray name(char separator='-') const
static Q_AUTOTEST_EXPORT QLocaleId fromName(QStringView name)