[Development] Why can't QString use UTF-8 internally?

Mark Gaiser markg85 at gmail.com
Wed Feb 11 10:32:22 CET 2015


On Wed, Feb 11, 2015 at 12:33 AM, Thiago Macieira <thiago.macieira at intel.com
> wrote:

> On Tuesday 10 February 2015 23:17:21 Allan Sandfeld Jensen wrote:
> > Maybe with C++11 we don't need QString that much anymore. Use std::string
> > with UTF8 and std::u32string for UCS4.
> >
> > For Qt6 it would be worth considering how many of our classes still makes
> > sense. Those we want CoW semantics on would make sense, but if we don't
> > really want that on strings, maybe every framework having its own string
> > class is finally obsolete in C++?
>
> Eh... have you tried to convert a UTF-8 or UTF-16 or UCS-4 string to the
> locale's narrow character set without using QString?
>
> Have you tried to convert a number to string? You need C++14 to do that
> reasonably, since std::to_string didn't exist in C++11. How about the
> reverse?
> The only way to do that is sscanf or std::istringstream.
>

What do you mean with C++14? According to cppreference [1] C++11 allows
this just fine.
[1] http://en.cppreference.com/w/cpp/string/basic_string/to_string

>
> Have you tried to uppercase or lowercase a string using only the Standard
> Library?
>

std::string s("hello");
std::transform(s.begin(), s.end(), s.begin(), ::toupper);

and
std::transform(s.begin(), s.end(), s.begin(), ::tolower);

Not sure about the performance though :)


> We may want to have this discussion for QVector vs std::vector. For QString
> and QByteArray, there's no discussion: they stay, period.
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150211/8f1a0968/attachment.html>


More information about the Development mailing list