QString: add fromRawData with a char16_t pointer
And I've updated the documentation to use char16_t too, making this the primary (recommended) overload over the QChar one. [ChangeLog][QtCore][QString] Added fromRawData() overload taking char16_t* (was: only QChar*). Change-Id: Iad8dd905a494706d72c4fffd40ded1cbf7122597 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
ba18ae3869
commit
4b278fd998
@ -344,12 +344,11 @@ void Widget::fromRawDataFunction()
|
|||||||
{
|
{
|
||||||
//! [22]
|
//! [22]
|
||||||
QRegularExpression pattern("\u00A4");
|
QRegularExpression pattern("\u00A4");
|
||||||
static const QChar unicode[] = {
|
static const char16_t unicode[] = {
|
||||||
0x005A, 0x007F, 0x00A4, 0x0060,
|
0x005A, 0x007F, 0x00A4, 0x0060,
|
||||||
0x1009, 0x0020, 0x0020};
|
0x1009, 0x0020, 0x0020};
|
||||||
qsizetype size = sizeof(unicode) / sizeof(QChar);
|
|
||||||
|
|
||||||
QString str = QString::fromRawData(unicode, size);
|
QString str = QString::fromRawData(unicode, std::size(unicode));
|
||||||
if (str.contains(pattern) {
|
if (str.contains(pattern) {
|
||||||
// ...
|
// ...
|
||||||
//! [22] //! [23]
|
//! [22] //! [23]
|
||||||
|
@ -9378,6 +9378,9 @@ QString::iterator QString::erase(QString::const_iterator first, QString::const_i
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\fn QString QString::fromRawData(const char16_t *unicode, qsizetype size)
|
||||||
|
\since 6.10
|
||||||
|
|
||||||
Constructs a QString that uses the first \a size Unicode characters
|
Constructs a QString that uses the first \a size Unicode characters
|
||||||
in the array \a unicode. The data in \a unicode is \e not
|
in the array \a unicode. The data in \a unicode is \e not
|
||||||
copied. The caller must be able to guarantee that \a unicode will
|
copied. The caller must be able to guarantee that \a unicode will
|
||||||
@ -9403,6 +9406,11 @@ QString::iterator QString::erase(QString::const_iterator first, QString::const_i
|
|||||||
\sa fromUtf16(), setRawData(), data(), constData(),
|
\sa fromUtf16(), setRawData(), data(), constData(),
|
||||||
nullTerminate(), nullTerminated()
|
nullTerminate(), nullTerminated()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QString QString::fromRawData(const QChar *unicode, qsizetype size)
|
||||||
|
\overload
|
||||||
|
*/
|
||||||
QString QString::fromRawData(const QChar *unicode, qsizetype size)
|
QString QString::fromRawData(const QChar *unicode, qsizetype size)
|
||||||
{
|
{
|
||||||
return QString(DataPointer::fromRawData(const_cast<char16_t *>(reinterpret_cast<const char16_t *>(unicode)), size));
|
return QString(DataPointer::fromRawData(const_cast<char16_t *>(reinterpret_cast<const char16_t *>(unicode)), size));
|
||||||
|
@ -782,6 +782,10 @@ public:
|
|||||||
}
|
}
|
||||||
static QString fromUtf16(const char16_t *, qsizetype size = -1);
|
static QString fromUtf16(const char16_t *, qsizetype size = -1);
|
||||||
static QString fromUcs4(const char32_t *, qsizetype size = -1);
|
static QString fromUcs4(const char32_t *, qsizetype size = -1);
|
||||||
|
static QString fromRawData(const char16_t *unicode, qsizetype size)
|
||||||
|
{
|
||||||
|
return QString(DataPointer(nullptr, const_cast<char16_t *>(unicode), size));
|
||||||
|
}
|
||||||
static QString fromRawData(const QChar *, qsizetype size);
|
static QString fromRawData(const QChar *, qsizetype size);
|
||||||
|
|
||||||
#if QT_DEPRECATED_SINCE(6, 0)
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user