[Development] QUtf8String{, View}

Konstantin Ritt ritt.ks at gmail.com
Sat May 16 20:23:27 CEST 2020

I facing a discussion like this every couple of months ;)

Yes, we should have a b with accent, cause it is exactly what the
programmer asked QString for; it is not our fault if b with accent is not
what he meant to get after replace.
QString (like any other tool) must not be used blindly or with zero
knowledge about what it operates on and what the expected result is.

s.length() - is not about amount of characters in the string; s.at(i) -
does not return the i'th character in the string; and surely
QUtf(8|32)String.replace('a', 'b') won't behave any "better" (I mean there
won't be any magic behind the scenes that would save some idiot from
writing some dumb code).


сб, 16 мая 2020 г. в 19:17, Thiago Macieira <thiago.macieira at intel.com>:

> On sábado, 16 de maio de 2020 08:52:19 PDT Arnaud Clère wrote:
> > Regarding the relevance of a QUtf8String, I feel like it would not be so
> > useful unless it allows to view its content as QChar instead of char (or
> > char8_t) since handling multibyte characters is so error prone. At least
> a
> > QChar handles most unicode characters as single entities...
> QUtf8StringIterator can be easily added to extract Unicode codepoints from
> the
> UTF-8 string like QStringIterator exists for the same in UTF-16.
> Usually, though, this means you're doing something wrong. Grapheme
> clusters
> can span multiple codepoints. Unless you're doing text shaping, you
> probably
> don't need them. And if you don't need them, why do you care about
> codepoints
> in the first place?
> That opens a philosophical question. In:
>     QString s = u"a a\u0301"; // U+0301 COMBINING ACUTE ACCENT
>     s.replace('a', 'b');
> Should we now have a b with accent? (b́)
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel System Software Products
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200516/81196c56/attachment.html>

More information about the Development mailing list