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

Tor Arne Vestbø Tor.arne.Vestbo at qt.io
Fri Jan 18 17:57:19 CET 2019



> On 18 Jan 2019, at 17:21, Thiago Macieira <thiago.macieira at intel.com> wrote:
> 
> On Friday, 18 January 2019 08:13:40 PST Kai Koehne wrote:
>> 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.
> 
> Actually, what we should do is allow everywhere
> 
> 	functionTakingString(u"Tor Arne Vestbø")
> 	// (note the u)

Yes, this would be awesome! Please let’s do this 😊

And I guess without QT_NO_CAST_FROM_ASCII you’d still be able to do:

  functionTakingString("Tor Arne Vestbø”) // without the ‘u’, runtime cost

Tor Arne 



More information about the Development mailing list