[Development] HEADS-UP: QStringLiteral
Mutz, Marc
marc at kdab.com
Thu Aug 22 15:15:27 CEST 2019
On 2019-08-22 14:59, Kevin Kofler wrote:
> Mutz, Marc via Development wrote:
>> For me, the problem is QUtf8XXX::size() - what should that return?!
>
> IMHO, obviously the number of bytes. You can have additional O(N)
> numCodePoints() and (if needed) utf16Size() (which takes needed
> surrogate
> pairs into account) methods, but the inherent size is the number of
> bytes.
>
>> IOW: what's the meaning of an index into a UTF-8 string? That extends
>> to
>> mid(), left(), right(), split(), ...
>
> IMHO, a byte index, and if that chops the codepoint, so be it, same as
> for
> the surrogate pairs in the UTF-16 QString. Anything else is just not
> doable
> with reasonable efficiency.
That I would see the day I agree with you... :)
But that leaves the task of identifying which of pre-existing size()
calls mean "number of characters" and which ones do "number of code
points" to the users. And it makes rightJustified() and leftJustified()
all but pointless. So this isn't without problems, but I agree the
alternative is worse.
Thanks,
Marc
More information about the Development
mailing list