summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-10-13 18:26:43 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-15 07:36:44 +0000
commit367ef5cebde581c9da9f78f703d8606237d252c7 (patch)
treec8f3055bf9b3ba958b2087e582003cf6986a8ef2
parentde9505a8942ef4068755893c648f6538ebcf3880 (diff)
Convert Latin1 to UTF-16 before passing to ICU API
The ICU UChar type is a UTF-16 type, not a single-byte type, so passing it the data() of a QByteArray representing an ID is misguided. Fixes: QTBUG-97486 Change-Id: I6789f491674b1d913eb8655d788b497e2fc06f7a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f83a3c4b6e703d3d6b48f2f8d2f71ab69c084b8f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/time/qtimezoneprivate_icu.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/time/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp
index 706deb2b17..89fee181ea 100644
--- a/src/corelib/time/qtimezoneprivate_icu.cpp
+++ b/src/corelib/time/qtimezoneprivate_icu.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 John Layt <jlayt@kde.org>
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -264,11 +265,10 @@ static QList<QByteArray> uenumToIdList(UEnumeration *uenum)
static int ucalDaylightOffset(const QByteArray &id)
{
UErrorCode status = U_ZERO_ERROR;
- const int32_t dstMSecs = ucal_getDSTSavings(reinterpret_cast<const UChar *>(id.data()), &status);
- if (U_SUCCESS(status))
- return (dstMSecs / 1000);
- else
- return 0;
+ const QString utf16 = QString::fromLatin1(id);
+ const int32_t dstMSecs = ucal_getDSTSavings(
+ reinterpret_cast<const UChar *>(utf16.data()), &status);
+ return U_SUCCESS(status) ? dstMSecs / 1000 : 0;
}
// Create the system default time zone