summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/code/src_corelib_text_qstringiterator.cpp
blob: 6b04d23b97f169bb58f2e86bc00f13ac33a4f00a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QString>
#include <QStringIterator>
#include <QDebug>

int main()
{

{
//! [0]
QString string(QStringLiteral("a string"));
QStringIterator i(string); // implicitly converted to QStringView
//! [0]

//! [1]
while (i.hasNext())
    uint c = i.next();
//! [1]
}

{
//! [2]
QStringIterator i(u"𝄞 is the G clef");
qDebug() << Qt::hex << i.next(); // will print '𝄞' (U+1D11E, MUSICAL SYMBOL G CLEF)
qDebug() << Qt::hex << i.next(); // will print ' ' (U+0020, SPACE)
qDebug() << Qt::hex << i.next(); // will print 'i' (U+0069, LATIN SMALL LETTER I)
//! [2]
}

}