From 0c50edbe84914469973a3b10e0170023ccdd66fe Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Feb 2017 10:19:37 +0100 Subject: QCollator: don't pipe bcp47Name() through QString Give QCollator access to QLocalePrivate::bcp47Name(), to avoid both the latin-1 -> UTF-16 conversion in QLocale::bcp47Name(), as well all as - the replace('-', '_').toLatin1() call in ICU - the toLocal8Bit() call in macOS - the toUtf8() call in Windows implementations of QCollatorPrivate::init(). This is safe, since, according to https://tools.ietf.org/html/bcp47, a BCP47 name only contains US-ASCII (ALPHA used, which is defined by https://tools.ietf.org/html/rfc5234 to be [a-zA-Z] only). Change-Id: Id56befb1b5a7983494d848cdabf7ebeda377cf9f Reviewed-by: Lars Knoll --- src/corelib/tools/qcollator_macx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools/qcollator_macx.cpp') diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index b4d93e58d4..c4eb8e6978 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -38,9 +38,12 @@ ****************************************************************************/ #include "qcollator_p.h" +#include "qlocale_p.h" #include "qstringlist.h" #include "qstring.h" + #include + #include #include @@ -53,7 +56,7 @@ void QCollatorPrivate::init() { cleanup(); LocaleRef localeRef; - int rc = LocaleRefFromLocaleString(locale.bcp47Name().toLocal8Bit(), &localeRef); + int rc = LocaleRefFromLocaleString(QLocalePrivate::get(locale)->bcp47Name().constData(), &localeRef); if (rc != 0) qWarning("couldn't initialize the locale"); -- cgit v1.2.3