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
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to