forked from qt-creator/qt-creator
Utils: Enable to construct Utf8String with the string literal
It does not make any sense to specify the number of letters and it is passed to QByteArray anyways which also accepts -1. Change-Id: If3a9d8cb039853c7b29ea9c73828fb1983e2f584 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
class Utf8StringVector;
|
class Utf8StringVector;
|
||||||
@@ -45,10 +46,13 @@ class Utf8String
|
|||||||
public:
|
public:
|
||||||
Utf8String() = default;
|
Utf8String() = default;
|
||||||
|
|
||||||
|
explicit Utf8String(const char *utf8Text)
|
||||||
|
: byteArray(utf8Text, utf8Text ? static_cast<int>(std::strlen(utf8Text)) : -1)
|
||||||
|
{}
|
||||||
|
|
||||||
explicit Utf8String(const char *utf8Text, int size)
|
explicit Utf8String(const char *utf8Text, int size)
|
||||||
: byteArray(utf8Text, size)
|
: byteArray(utf8Text, size)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
Utf8String(const QString &text)
|
Utf8String(const QString &text)
|
||||||
: byteArray(text.toUtf8())
|
: byteArray(text.toUtf8())
|
||||||
|
|||||||
Reference in New Issue
Block a user