[Development] RFC: Defaulting to or enforcing UTF-8 locales on Unix systems

Thiago Macieira thiago.macieira at intel.com
Fri Nov 15 08:20:08 CET 2019

On Thursday, 14 November 2019 13:27:23 PST André Pönitz wrote:
> *Within* a Qt application consisting of Qt library, other libraries,
> and actual user code it's mildly presumptous for one library to impose
> random unnecessay restrictions on user code and other libraries.

That boat sailed 20 years ago when we started calling setlocale() from 
QCoreapplication. We set the locale, period.

The questions are:
1) do we want to prevent another library from accidentally unsetting it?
2) do we want child processes to use the same?

Note the answers for both questions must be the same, for the solution is the 
same. So either both yeses or both nos.

> Making assumptions on the controlability of content of a input stream is
> questionable. The proposed method of changing the environment for child
> processes is no guarantee on what the child actually produces, and the
> Qt application still has to be prepared to handle non-Utf-8 or otherwise
> "broken" input.

Qt 6 will not have support for non-UTF-8 codecs, outside of Windows. You can 
either deal with binary data or with UTF-8 text, there's no middle ground.

> This discussion so far claimed the existance of a range of problems
> without giving an actual example. Then it goes on to propose a shotgut
> approach (LC_ALL, "ALL") to handle ... what? "Obscure locale settings"
> like categories that are a bit more fine grained than LC_ALL?  Bear with
> me when I do not have the impression that Qt will be the right context
> to accept such "obligations".

The same argument can be made for your statements: you're arguing that here 
are broken applications that won't handle C.UTF-8 correctly, without giving as 
single example.

I think the whole problem is that we're trying to talk about broken 
applications and the way their brokenness manifests itself. I don't think such 
applications exist anymore in occurrence sufficient for us to deal with.

Anyway, since you oppose setting the environment, let's just make a check for 

if (locale is not UTF-8)
    qFatal("Qt only supports UTF-8 locales. "
           "Please configure your system properly");

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products

More information about the Development mailing list