[Development] Qt6: Adding UTF-8 storage support to QString

Thiago Macieira thiago.macieira at intel.com
Tue Jan 22 20:47:36 CET 2019

On Tuesday, 22 January 2019 09:01:16 PST Arnaud Clère wrote:
> QByteArray is the official way to deal with utf8 strings but:
> 1. This discussion shows it is not as known as it should be and I argue the
> name does not help 
> 2. Dealing with binary data and all kind of string
> encodings in a single class is error-prone

And yet that's what we used to have in Qt 3 (remember QCString?). We went away 
from it for a reason.

And 3: some character-mutating operations in QByteArray (toUpper, etc.) are 
Latin1, not UTF-8.

> Hence my suggestion of adding a QUtf8String deriving from QByteArray...

Not likely to happen. If we add a QUtf8String, it will be like QLatin1String, 
which in turn was meant to be similar to QStringView, not like QString. That 
means no mutation and no owning memory.

And I don't want to add QUtf8String until SG16's char8_t gets settled. It'll 
probably be settled by C++20, which means we can probably work on this during 
Qt 6 lifetime, possibly even 6.1 or 6.2.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list