QCoreApplications sets QTextCodec::codecForLocale() incorrectly

Bug #1874832 reported by tom stevens
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qtbase-opensource-src (Ubuntu)
New
Undecided
Unassigned

Bug Description

With ICU versions >= 61 QTextCodec::codecForLocale() always returns the utf-8 codec with mib 106 regardless of the value of the environmental variable LC_ALL or the available locales.

On bionic, which included ICU 60, codecForLocale() returned the correct codec. On eoan and focal, which include ICU 63 and ICU 66, the utf-8 codec is always returned.

The change in behavior is expected due to a documented change in ICU https://github.com/unicode-org/icu/commit/d7482c9720b4f71dd9dad0.
However, Qt has not accounted for this change in ICU.

I note that Qt 5.12.8 from https://download.qt.io/archive/qt/5.12/5.12.8/ is packaged with an older version of ICU so the combination works correctly. But on Ubuntu eoan and focal the included version of ICU is not compatible with the included Qt.

The included file localetrouble.tar contains
1) demo: a script that builds two tests cases and runs them
2) focal.log: the results of running the demo script on focal
3) bionic.log: the results of running the demo script on bionic
4) test1.cc: a minimal Qt Core application that tries to use the codec from the current locale.
5) test1.pro: Qt pro file used to build test1.cc
6) test2.cc: a test program that shows why Qt fails to detect the correct locale. These two lines are executed by QCoreApplicationPrivate::initLocale() and *QIcuCodec::defaultCodecUnlocked().
7) test2.pro: Qt pro file used to build test2.cc

The expected results of test1 are that codecForLocale is set based on LC_ALL to en_US.iso88591:
env LC_ALL=en_US.iso88591 ./test1
QTextCodec::codecForLocale(): "ISO-8859-1" , mib 4
LC_ALL: en_US.iso88591

The actual results on focal are:
env LC_ALL=en_US.iso88591 ./test1
QTextCodec::codecForLocale(): "UTF-8" , mib 106
LC_ALL: en_US.iso88591

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: qtbase5-dev 5.12.8+dfsg-0ubuntu1
ProcVersionSignature: Ubuntu 4.15.0-96.97-generic 4.15.18
Uname: Linux 4.15.0-96-generic x86_64
ApportVersion: 2.20.11-0ubuntu27
Architecture: amd64
CasperMD5CheckResult: skip
Date: Fri Apr 24 14:45:36 2020
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
SourcePackage: qtbase-opensource-src
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
tom stevens (tsteven4) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.