[Development] Qt6: Adding UTF-8 storage support to QString
Thiago Macieira
thiago.macieira at intel.com
Fri Jan 18 17:09:58 CET 2019
On Friday, 18 January 2019 07:26:51 PST Tor Arne Vestbø wrote:
> 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 we now can. The last problem we had was MSVC pre-2015 update 2, which
added the /utf-8 switch. Without that option, any non-ASCII character in the
source code, even in comments, could cause compilation errors by causing a
decoding error in whichever codepage the user used in his/her OS.
I think all our builds now use /utf-8, which means UTF-8 is permitted
everywhere now. You can use it in comments ("Copyright Klarälvdalens ...", for
example) and in strings. Please don't use it in identifiers.
As for strings, the QString constructor takes UTF-8 input, but however fast
the decoder is, it's still slightly slower than the Latin1 decoder. So if your
string is purely US-ASCII, using QLatin1String is recommended.
PS: we don't need SG16's char8_t, but we'll need to add support for it.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list