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

Kai Koehne Kai.Koehne at qt.io
Fri Jan 18 17:13:40 CET 2019

> -----Original Message-----
> From: Development <development-bounces at qt-project.org> On Behalf Of Tor
> Arne Vestbø
> Sent: Friday, January 18, 2019 4:27 PM
> To: Jedrzej Nowacki <Jedrzej.Nowacki at qt.io>
> Cc: Thiago Macieira <thiago.macieira at intel.com>; development at qt-
> project.org
> Subject: Re: [Development] Qt6: Adding UTF-8 storage support to QString
> Picking up on this:
> If we plan to standardise on our Qt source code being UTF8, can we please
> allow QString(“Tor Arne Vestbø") without going through
> QLatin1Literal/QStringLiteral/QLatin1String/etc etc?

I think you're touching two different things here:

1. We generally compile Qt code with QT_NO_CAST_FROM_ASCII that disables the QString(const char *) overload. And we do that so that you have to make it explicit whether you really want to do the implicit conversion from UTF-8 to UTF-16, use QStringLiteral() to encode it as UTF-16 at compile time, or rather have it translated with a  tr() call.

I think for Qt code explicit is better than implicit, so I actually would stay with QT_NO_CAST_FROM_ASCII.

2. We require all Qt source code to be ASCII only. This is AFAIK mostly because of the editor in Visual Studio, who's even in its latest incarnation doesn't have a global option to save files in UTF-8 instead of <your-local-Windows-codepage>.

Here I'm not sure anymore whether being conservative buys us much. VS after all has a heuristic to open a UTF-8 encoded file correctly, so the problem mostly is that people might create a new file with non-UTF-8 content, or copy it from another project.



More information about the Development mailing list