diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-02-07 10:19:37 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-02-07 19:40:10 +0000 |
commit | 0c50edbe84914469973a3b10e0170023ccdd66fe (patch) | |
tree | a32fb8f572480267c8ba2e6569da3538218e951d /src/corelib/tools/qcollator_icu.cpp | |
parent | 9aaaa8427d5d9e9141e0b1b02595a6b96f37cb0c (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/tools/qcollator_icu.cpp')
-rw-r--r-- | src/corelib/tools/qcollator_icu.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index 3cde3051b4..98bed1fbca 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ #include "qcollator_p.h" +#include "qlocale_p.h" #include "qstringlist.h" #include "qstring.h" @@ -56,7 +57,7 @@ void QCollatorPrivate::init() cleanup(); UErrorCode status = U_ZERO_ERROR; - QByteArray name = locale.bcp47Name().replace(QLatin1Char('-'), QLatin1Char('_')).toLatin1(); + QByteArray name = QLocalePrivate::get(locale)->bcp47Name('_'); collator = ucol_open(name.constData(), &status); if (U_FAILURE(status)) { qWarning("Could not create collator: %d", status); |